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.
 
 
 
 
 
 

1051 lines
41 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.change.mapper.ChangeManagementMapper">
<!-- 技术参数卡列表 -->
<select id="technicalSpecificationSearch" parameterType="TechnicalSpecificationData" resultType="TechnicalSpecificationData">
SELECT
a.site,
b.bu_no,
a.test_part_no as partNo,
dbo.get_part_name(a.site, a.test_part_no) as partDesc,
a.project_id,
c.project_name as project_desc,
c.customer_id,
j.customer_desc,
a.code_no,
a.rev_no,
case when a.ECN_flag = 'Y' then '变更中' else '未发起' end as ecnFlag,
a.ECN_no,
a.ECN_address
FROM plm_technical_specification_sheet a
LEFT JOIN view_Project_Part b ON a.site = b.site AND a.test_part_no = b.final_part_no AND a.project_id = b.project_id
LEFT JOIN plm_project_info c ON a.site = c.site AND a.project_id = c.project_id
LEFT JOIN plm_customer_information j ON j.site = c.site and j.customer_no = c.customer_id
<where>
a.site = #{query.site} AND (a.ECN_flag is null or a.ECN_flag = 'N')
<if test = "query.buNo != null and query.buNo != ''">
AND b.bu_no = #{query.buNo}
</if>
<if test = "query.partNo != null and query.partNo != ''">
AND a.test_part_no like #{query.partNo}
</if>
<if test = "query.partDesc != null and query.partDesc != ''">
AND dbo.get_part_name(a.site, a.test_part_no) like #{query.partDesc}
</if>
<if test = "query.customerId != null and query.customerId != ''">
AND c.customer_id like #{query.customerId}
</if>
<if test = "query.customerDesc != null and query.customerDesc != ''">
AND j.customer_desc like #{query.customerDesc}
</if>
<if test = "query.projectId != null and query.projectId != ''">
AND a.project_id like #{query.projectId}
</if>
<if test = "query.projectDesc != null and query.projectDesc != ''">
AND c.project_name like #{query.projectDesc}
</if>
<if test = "query.codeNo != null and query.codeNo != ''">
AND a.code_no like #{query.codeNo}
</if>
</where>
</select>
<!-- 根据用户编码获得用户部门 -->
<select id="getDepartmentByUserName" resultType="com.spring.modules.change.vo.SysUserVo" parameterType="com.spring.modules.change.vo.SysUserVo">
SELECT
a.site,
a.user_id,
a.username,
a.password,
a.salt,
a.email,
a.mobile,
a.status,
a.create_user_id,
a.create_time,
a.language_default,
a.user_display,
a.bu_no,
a.post_no,
a.department_no,
b.department_name
FROM sys_user as a
LEFT JOIN department as b on a.site = b.site and a.department_no = b.department_no
WHERE a.site = #{site} and a.username = #{username}
</select>
<!-- 根据变更单号删除文件 -->
<delete id="deleteChangeFiles" parameterType="ChangeRequestEntity">
delete from sys_oss
where order_ref1 = #{site} and order_ref2 = #{changeNo}
</delete>
<!-- 新增变更详情 -->
<insert id="saveChangeRequestDetail">
insert into plm_change_request_detail
(site, change_no, code_no, rev_no, part_no, part_desc, drawing_no, draft_no, new_part_no, new_drawing_no, new_draft_no, create_date, create_by) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.changeNo}, #{item.codeNo}, #{item.revNo}, #{item.partNo}, #{item.partDesc}, #{item.drawingNo}, #{item.draftNo}, #{item.newPartNo}, #{item.newDrawingNo}, #{item.newDraftNo}, getDate(), #{item.createBy})
</foreach>
</insert>
<!-- 修改技术参数卡的ECN状态 -->
<update id="updateTechnicalSpecificationSheet">
update plm_technical_specification_sheet
set ECN_flag = 'Y',
ECN_no = #{changeNo},
update_date = getDate(),
update_by = #{createBy}
where site = #{site}
AND code_no in (
<foreach collection="ids" item="item" separator=",">
#{item}
</foreach>
)
</update>
<!-- =============================================================================================================== -->
<!-- 工程变更记录列表 -->
<select id="changeRecordSearch" parameterType="com.spring.modules.change.vo.ChangeRequestVo" resultType="com.spring.modules.change.vo.ChangeRequestVo">
SELECT
a.site,
a.change_no,
a.applicant_id,
dbo.get_userDisPlay(a.applicant_id) as applicantName,
b.department_no as applicationDepartmentId,
dbo.get_department_name(a.site, b.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,
a.step_id,
a.reject_flag,
a.reject_step_id,
d.is_reject,
d.node_id,
d.node_name
FROM plm_change_request a
LEFT JOIN sys_user as b on a.site = b.site and a.applicant_id = b.username
left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{query.menuId}
left join plm_request_node as d on a.site = d.site and prh.classification_no = d.classification_no and prh.workflow_id = d.workflow_id and a.step_id = d.step_id
<where>
a.site = #{query.site}
<if test = "query.changeNo != null and query.changeNo != ''">
AND a.change_no like #{query.changeNo}
</if>
</where>
</select>
<!-- 变更单详情的列表 -->
<select id="changeDetailSearch" parameterType="com.spring.modules.change.vo.ChangeRequestDetailVo" resultType="com.spring.modules.change.vo.ChangeRequestDetailVo">
SELECT
a.site,
a.change_no,
a.code_no,
a.rev_no,
a.part_no,
a.part_desc,
a.drawing_no,
a.draft_no,
a.new_part_no,
a.new_drawing_no,
a.new_draft_no,
a.create_date,
a.create_by,
a.update_date,
a.update_by
FROM plm_change_request_detail a
where a.site = #{site} and a.change_no = #{changeNo}
</select>
<!-- 查询库存成本影响 -->
<select id="costImpactSearch" parameterType="ChangeRequestEntity" resultType="com.spring.modules.change.vo.ChangeCostImpactVo">
SELECT
site,
change_no,
production_product_flag,
inventory_product_flag,
new_order_flag,
affected_flag,
production_product_number,
production_product_opinions,
production_product_scrap_amount,
production_product_remark,
production_product_executor,
dbo.plm_get_user_display(site, production_product_executor) as productionProductExecutorName,
inventory_product_number,
inventory_product_opinions,
inventory_product_scrap_amount,
inventory_product_remark,
inventory_product_executor,
dbo.plm_get_user_display(site, inventory_product_executor) as inventoryProductExecutorName,
new_order_number,
affected_number,
affected_opinions,
affected_scrap_amount,
affected_remark,
affected_executor,
dbo.plm_get_user_display(site, affected_executor) as affectedExecutorName,
change_total_cost,
remark,
create_date,
create_by,
update_date,
update_by
FROM plm_change_cost_impact
where site = #{site} and change_no = #{changeNo}
</select>
<!-- 库存成本影响新增 -->
<insert id="costImpactSave" parameterType="ChangeCostImpactEntity">
INSERT INTO plm_change_cost_impact
(site, change_no, production_product_flag, inventory_product_flag, new_order_flag, affected_flag, production_product_number, production_product_opinions,
production_product_remark, production_product_executor, inventory_product_number, inventory_product_opinions, inventory_product_remark, inventory_product_executor,
new_order_number, affected_number, affected_opinions, affected_remark, affected_executor, change_total_cost, remark, create_date, create_by,
production_product_scrap_amount, inventory_product_scrap_amount, affected_scrap_amount)
VALUES
(#{site}, #{changeNo}, #{productionProductFlag}, #{inventoryProductFlag}, #{newOrderFlag}, #{affectedFlag}, #{productionProductNumber}, #{productionProductOpinions},
#{productionProductRemark}, #{productionProductExecutor}, #{inventoryProductNumber}, #{inventoryProductOpinions}, #{inventoryProductRemark}, #{inventoryProductExecutor},
#{newOrderNumber}, #{affectedNumber}, #{affectedOpinions}, #{affectedRemark}, #{affectedExecutor}, #{changeTotalCost}, #{remark}, getDate(), #{createBy},
#{productionProductScrapAmount}, #{inventoryProductScrapAmount}, #{affectedScrapAmount})
</insert>
<!-- 查询执行信息 -->
<select id="queryChangeExecutionInfo" parameterType="com.spring.modules.change.vo.ChangeExecutionInfoVo" resultType="ChangeExecutionInfoEntity">
SELECT
site,
change_no,
original_film_no,
new_film_no,
original_die_cutting_rule_no,
new_die_cutting_rule_no,
original_stencil_no,
new_stencil_no,
execution_date,
create_date,
create_by,
update_date,
update_by
FROM plm_change_execution_info
where site = #{site} and change_no = #{changeNo}
</select>
<!-- 执行信息新增 -->
<insert id="executionSave" parameterType="com.spring.modules.change.vo.ChangeExecutionInfoVo">
INSERT INTO plm_change_execution_info
(site, change_no, original_film_no, new_film_no, original_die_cutting_rule_no, new_die_cutting_rule_no, original_stencil_no, new_stencil_no, execution_date, create_date, create_by)
VALUES
(#{site}, #{changeNo}, #{originalFilmNo}, #{newFilmNo}, #{originalDieCuttingRuleNo}, #{newDieCuttingRuleNo}, #{originalStencilNo}, #{newStencilNo}, #{executionDate}, getDate(), #{createBy})
</insert>
<!-- 判断所选技术参数卡状态 -->
<select id="queryTechnicalSpecificationSheet" resultType="TechnicalSpecificationData">
SELECT
site,
code_no,
ECN_flag,
ECN_no
FROM plm_technical_specification_sheet
where site = #{site}
AND code_no in (
<foreach collection="ids" item="item" separator=",">
#{item}
</foreach>
)
</select>
<!-- 编辑库存成本影响 -->
<update id="costImpactUpdate" parameterType="ChangeCostImpactEntity">
update plm_change_cost_impact
set production_product_flag = #{productionProductFlag},
inventory_product_flag = #{inventoryProductFlag},
new_order_flag = #{newOrderFlag},
affected_flag = #{affectedFlag},
production_product_number = #{productionProductNumber},
production_product_opinions = #{productionProductOpinions},
production_product_remark = #{productionProductRemark},
production_product_executor = #{productionProductExecutor},
inventory_product_number = #{inventoryProductNumber},
inventory_product_opinions = #{inventoryProductOpinions},
inventory_product_remark = #{inventoryProductRemark},
inventory_product_executor = #{inventoryProductExecutor},
new_order_number = #{newOrderNumber},
affected_number = #{affectedNumber},
affected_opinions = #{affectedOpinions},
affected_remark = #{affectedRemark},
affected_executor = #{affectedExecutor},
change_total_cost = #{changeTotalCost},
remark = #{remark},
update_date = getDate(),
update_by = #{createBy},
production_product_scrap_amount = #{productionProductScrapAmount},
inventory_product_scrap_amount = #{inventoryProductScrapAmount},
affected_scrap_amount = #{affectedScrapAmount}
where site = #{site} and change_no = #{changeNo}
</update>
<!-- 查询ECN种类数据 -->
<select id="getEcnTypeHeader" parameterType="EcnTypeHeaderData" resultType="EcnTypeHeaderData">
SELECT
site,
dict_id,
dict_name,
dict_type as value
FROM sys_dict_type
where site = #{site} and dict_type like 'change_ecn_type_%' and status = 'Y'
</select>
<!-- 查询ECN种类数据 -->
<select id="getEcnTypeDetail" parameterType="EcnTypeHeaderData" resultType="EcnTypeDetailData">
SELECT
site,
dict_value as value
FROM sys_dict_data
where site = #{site} and dict_type = #{value} and status = 'Y'
</select>
<!-- 新增ECN种类header -->
<insert id="saveEcnTypeHeader">
insert into plm_change_ecn_type_header
(site, change_no, header_value, flag) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.changeNo}, #{item.value}, #{item.flag})
</foreach>
</insert>
<!-- 新增ECN种类detail -->
<insert id="saveEcnTypeDetail">
insert into plm_change_ecn_type_detail
(site, change_no, header_value, value, flag) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.changeNo}, #{item.headerValue}, #{item.value}, #{item.flag})
</foreach>
</insert>
<!-- 查询ECN的模板 -->
<select id="getEcnModel" parameterType="PlmPropertiesModelHeaderData" resultType="PlmPropertiesModelHeaderData">
SELECT
site,
function_type,
code_no,
code_desc
FROM plm_properties_model_header
<where>
site = #{site} and function_type = #{functionType} and code_no = #{codeNo}
</where>
</select>
<!-- 查询模板属性 -->
<select id="getItemList" parameterType="PlmPropertiesModelHeaderData" resultType="ChangeItemData">
SELECT
a.site,
a.properties_item_no as itemNo,
b.ItemDesc as itemDesc,
a.code_no,
b.ValueChooseFlag,
a.function_type
FROM plm_properties_model_detail as a
left join plm_properties_item as b on a.site = b.site and a.properties_item_no = b.ItemNo and a.function_type = b.ItemType
<where>
a.site = #{site} and a.function_type = #{functionType} and a.code_no = #{codeNo}
<if test="itemNo != null and itemNo != ''">
AND a.properties_item_no like #{itemNo}
</if>
<if test="itemDesc != null and itemDesc != ''">
AND b.ItemDesc like #{itemDesc}
</if>
</where>
</select>
<!-- 获取属性可选值 -->
<select id="getAvailableValueList" parameterType="ChangeItemData" resultType="PlmPropertiesItemAvailableData">
select
ItemNo,
ValueNo,
AvailableValue
from plm_properties_item_available
where itemNo = #{itemNo} and site = #{site} and ItemType = #{functionType}
</select>
<!-- 获取属性可选值 -->
<select id="getAvailableValueList2" parameterType="ChangeItemEntity" resultType="PlmPropertiesItemAvailableData">
select
ItemNo,
ValueNo,
AvailableValue
from plm_properties_item_available
where itemNo = #{itemNo} and site = #{site} and ItemType = 'ECN'
</select>
<!-- 新增变更单属性 -->
<insert id="chooseItemSave">
insert into plm_change_item
(site, change_no, item_no, item_desc, execute_flag, executor, item_execution_date, item_remark, create_date, create_by, code_no) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=DATE}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo})
</foreach>
</insert>
<!-- 新增可行性属性 -->
<insert id="chooseItemSave2">
insert into plm_change_FA_item
(site, change_no, item_no, item_desc, execute_flag, executor, item_execution_date, item_remark, create_date, create_by, code_no, choose_value) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=DATE}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo}, #{item.chooseValue})
</foreach>
</insert>
<!-- 查询执行对象 -->
<select id="executionInfoSearch" parameterType="ChangeRequestEntity" resultType="ChangeExecutionInfoEntity">
SELECT
site,
change_no,
original_film_no,
new_film_no,
original_die_cutting_rule_no,
new_die_cutting_rule_no,
original_stencil_no,
new_stencil_no,
execution_date,
create_date,
create_by,
update_date,
update_by
FROM plm_change_execution_info
where site = #{site} and change_no = #{changeNo}
</select>
<!-- 查询变更单属性 -->
<select id="changeItemSearch" parameterType="ChangeRequestEntity" resultType="ChangeItemEntity">
SELECT
site,
change_no,
item_no,
item_desc,
execute_flag,
executor,
item_execution_date,
item_remark,
create_date,
create_by,
update_date,
update_by,
code_no
FROM plm_change_item
where site = #{site} and change_no = #{changeNo}
</select>
<!-- 查询变更单属性 -->
<select id="changeItemSearch2" parameterType="ChangeRequestEntity" resultType="ChangeItemEntity">
SELECT
a.site,
a.change_no,
a.item_no,
a.item_desc,
a.execute_flag,
a.executor,
a.item_execution_date,
a.item_remark,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
a.code_no,
a.choose_value,
b.ValueChooseFlag
FROM plm_change_FA_item as a
left join plm_properties_item as b on a.site = b.site and a.item_no = b.ItemNo and b.ItemType = 'ECN'
where a.site = #{site} and a.change_no = #{changeNo}
</select>
<!-- 查询变更单会签属性 -->
<select id="changeCSItemSearch" parameterType="ChangeRequestEntity" resultType="ChangeCountersignatureItemEntity">
SELECT
site,
change_no,
item_no,
item_desc,
execute_flag,
executor,
item_execution_date,
item_remark,
create_date,
create_by,
update_date,
update_by,
code_no
FROM plm_change_countersignature_item
where site = #{site} and change_no = #{changeNo}
</select>
<!-- 查询变更明细 -->
<select id="requestDetailSearch" parameterType="ChangeRequestEntity" resultType="ChangeRequestDetailEntity">
SELECT
site,
change_no,
code_no,
rev_no,
part_no,
part_desc,
drawing_no,
draft_no,
new_part_no,
new_drawing_no,
new_draft_no,
create_date,
create_by,
update_date,
update_by
FROM plm_change_request_detail
where site = #{site} and change_no = #{changeNo}
</select>
<!-- 删除变更明细 -->
<delete id="deleteChangeDetail" parameterType="ChangeRequestDetailEntity">
delete from plm_change_request_detail
where site = #{site} and change_no = #{changeNo} and code_no = #{codeNo}
</delete>
<!-- 查询所选ECN种类Header -->
<select id="getChooseEcnTypeHeader" parameterType="ChangeRequestEntity" resultType="EcnTypeHeaderData">
SELECT
site,
change_no,
header_value as value,
flag
FROM plm_change_ecn_type_header
where site = #{site} and change_no = #{changeNo}
</select>
<!-- 查询所选ECN种类Detail -->
<select id="getChooseEcnTypeDetail" parameterType="EcnTypeHeaderData" resultType="EcnTypeDetailData">
SELECT
site,
change_no,
header_value,
value,
flag
FROM plm_change_ecn_type_detail
where site = #{site} and change_no = #{changeNo} and header_value = #{value}
</select>
<!-- 删除变更明细 -->
<delete id="deleteChangeDetails" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
delete from plm_change_request_detail
where site = #{site} and change_no = #{changeNo}
</delete>
<!-- 删除种类Header -->
<delete id="deleteEcnTypeHeaderByChangeNo" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
delete from plm_change_ecn_type_header
where site = #{site} and change_no = #{changeNo}
</delete>
<!-- 删除种类Detail -->
<delete id="deleteEcnTypeDetailByChangeNo" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
delete from plm_change_ecn_type_detail
where site = #{site} and change_no = #{changeNo}
</delete>
<!-- 查询工程变更记录 -->
<select id="selectChangeRequest" parameterType="com.spring.modules.change.vo.ChangeRequestVo" resultType="com.spring.modules.change.vo.ChangeRequestVo">
SELECT
a.site,
a.change_no,
a.applicant_id,
dbo.get_userDisPlay(a.applicant_id) as applicantName,
b.department_no as applicationDepartmentId,
dbo.get_department_name(a.site, b.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,
a.step_id,
a.reject_flag,
a.reject_step_id,
d.is_Reject
FROM plm_change_request a
LEFT JOIN sys_user as b on a.site = b.site and a.applicant_id = b.username
left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{menuId}
left join plm_request_node as d on a.site = d.site and prh.classification_no = d.classification_no and prh.workflow_id = d.workflow_id and a.step_id = d.step_id
where a.site = #{site} and a.change_no = #{changeNo}
</select>
<!-- 编辑库存成本影响 -->
<update id="executionUpdate" parameterType="com.spring.modules.change.vo.ChangeExecutionInfoVo">
update plm_change_execution_info
set original_film_no = #{originalFilmNo},
new_film_no = #{newFilmNo},
original_die_cutting_rule_no = #{originalDieCuttingRuleNo},
new_die_cutting_rule_no = #{newDieCuttingRuleNo},
original_stencil_no = #{originalStencilNo},
new_stencil_no = #{newStencilNo},
execution_date = #{executionDate},
update_date = getDate(),
update_by = #{createBy}
where site = #{site} and change_no = #{changeNo}
</update>
<!-- 编辑变更单属性 -->
<update id="chooseItemUpdate" parameterType="ChangeItemEntity">
update plm_change_item
set execute_flag = #{executeFlag},
executor = #{executor},
item_execution_date = #{itemExecutionDate},
item_remark = #{itemRemark},
update_date = getDate(),
update_by = #{createBy}
where site = #{site} and change_no = #{changeNo} and item_no = #{itemNo}
</update>
<!-- 编辑变更单属性 -->
<update id="chooseItemUpdate2" parameterType="ChangeItemEntity">
update plm_change_FA_item
set execute_flag = #{executeFlag},
executor = #{executor},
item_execution_date = #{itemExecutionDate},
item_remark = #{itemRemark},
update_date = getDate(),
update_by = #{createBy},
choose_value = #{chooseValue}
where site = #{site} and change_no = #{changeNo} and item_no = #{itemNo}
</update>
<!-- 编辑变更单属性 -->
<update id="chooseCSItemUpdate" parameterType="ChangeCountersignatureItemEntity">
update plm_change_countersignature_item
set execute_flag = #{executeFlag},
executor = #{executor},
item_execution_date = #{itemExecutionDate},
item_remark = #{itemRemark},
update_date = getDate(),
update_by = #{createBy}
where site = #{site} and change_no = #{changeNo} and item_no = #{itemNo}
</update>
<!-- 新增会签属性 -->
<insert id="chooseCSItemSave">
insert into plm_change_countersignature_item
(site, change_no, item_no, item_desc, execute_flag, executor, item_execution_date, item_remark, create_date, create_by, code_no) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=DATE}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo})
</foreach>
</insert>
<select id="queryRequestHeader" parameterType="string" resultType="com.spring.modules.request.vo.PlmRequestHeaderVo">
SELECT
a.site,
a.bu,
a.classification_no,
a.classification_name,
a.menu_id,
a.workflow_id,
b.workflowname,
a.status,
a.remark,
a.create_by,
a.create_date,
a.update_by,
a.update_date,
c.url
FROM plm_request_header a
LEFT JOIN [VIEW_Process_management_OA_PLM] b ON a.workflow_id = b.workflowid
left join sys_menu as c on a.menu_id = c.menu_id
WHERE a.site = #{site} and a.menu_id = #{menuId} and a.status = 'Y'
</select>
<select id="queryNodeDetailFirst" parameterType="string" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
SELECT
a.id,
a.site,
a.bu,
a.classification_no,
b.node_id,
a.node_name,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
a.remark,
a.plm_field,
a.oa_field,
a.field_value,
a.order_ref1,
a.order_ref2,
a.order_ref3,
a.order_ref4,
a.field_desc,
a.workflow_id,
a.plm_table,
a.field_type,
b.step_id
FROM plm_request_header as c
left join plm_request_node as b on c.site = b.site and c.bu = b.bu and c.classification_no = b.classification_no
LEFT JOIN plm_request_node_detail as a on a.classification_no = b.classification_no and a.node_id = b.node_id
WHERE b.site = #{site} and b.workflow_id = #{workflowId} and c.menu_id = #{menuId}
and b.node_id = (select top 1 node_id from plm_request_node where site = #{site} and workflow_id = #{workflowId} order by seq_no)
</select>
<select id="getSeqNo" parameterType="ProcessFormEntity" resultType="int">
SELECT
case when max(seq_no) is null THEN 1 ELSE max(seq_no) + 1 end
FROM plm_process_form
WHERE site = #{site} and bu = #{bu} and request_id = #{requestId}
</select>
<insert id="saveProcessForm" parameterType="ProcessFormEntity">
INSERT INTO plm_process_form
(site, bu, request_id, workflow_id, node_id, domain_control_account, document_no, document_type, seq_no, reject_flag, reject_node_id, node_conclusion, submit_date, submitted_by, create_date, create_by, is_remark, classification_no, step_id, menu_id)
VALUES
(#{site}, #{bu}, #{requestId}, #{workflowId}, #{nodeId}, #{domainControlAccount}, #{documentNo}, #{documentType}, #{seqNo}, #{rejectFlag}, #{rejectNodeId}, #{nodeConclusion}, #{submitDate}, #{submittedBy}, getDate(), #{createBy}, #{isRemark}, #{classificationNo}, #{stepId}, #{menuId})
</insert>
<!-- 编辑变更单属性 -->
<update id="updateChangeStatus" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
update plm_change_request
set change_status = #{changeStatus},
update_date = getDate(),
update_by = #{userName}
where site = #{site} and change_no = #{changeNo}
</update>
<select id="queryRequestId" parameterType="string" resultType="ProcessFormEntity">
SELECT
a.id,
a.site,
a.bu,
a.request_id,
a.workflow_id,
b.workflowname,
a.node_id,
a.domain_control_account,
a.document_no,
a.document_type,
a.seq_no,
a.reject_flag,
a.reject_node_id,
a.node_conclusion,
a.submit_date,
a.submitted_by,
a.is_remark,
a.classification_no,
a.menu_id,
c.url
FROM plm_process_form as a
LEFT JOIN [VIEW_Process_management_OA_PLM] as b ON a.workflow_id = b.workflowid and a.node_id = b.nodeid
left join sys_menu as c on a.menu_id = c.menu_id
WHERE a.site = #{site} and a.bu = #{bu} and a.document_no = #{documentNo} and a.is_remark = 0
</select>
<select id="queryNodeDetails" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
SELECT
id,
site,
bu,
classification_no,
node_id,
node_name,
create_date,
create_by,
update_date,
update_by,
remark,
plm_field,
oa_field,
field_value,
order_ref1,
order_ref2,
order_ref3,
order_ref4,
field_desc,
workflow_id,
plm_table,
field_type
FROM plm_request_node_detail
WHERE site = #{site} and workflow_id = #{workflowId} and node_id = #{nodeId} and classification_no = #{classificationNo}
</select>
<!-- 编辑变更单属性 -->
<update id="updateProcessForm" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
update plm_process_form
set is_remark = 1,
update_date = getDate(),
update_by = #{userName}
where site = #{site} and document_no = #{changeNo} and is_remark = 0
</update>
<!-- 编辑变更单属性 -->
<update id="updateStepId" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
update plm_change_request
set step_id = #{stepId}
<if test='rejectFlag == "Y"'>
reject_flag = 'Y',
</if>
where site = #{site} and change_no = #{changeNo}
</update>
<select id="getStepId" parameterType="string" resultType="int">
SELECT step_id
FROM plm_request_node
WHERE classification_no = #{classificationNo} and node_id = #{nodeId}
</select>
<!-- 编辑变更单的驳回标识 -->
<update id="updateChangeReject" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
update plm_change_request
set reject_flag = 'Y',
reject_step_id = #{rejectStepId}
where site = #{site} and change_no = #{changeNo}
</update>
<!-- 编辑流程记录的驳回标识 -->
<update id="updateProcessReject" parameterType="string">
update plm_process_form
set reject_flag = 'Y'
where site = #{site} and bu = #{bu} and request_id = #{requestId} and domain_control_account = #{domainControlAccount} and is_remark = 0
</update>
<select id="getProcessNodeId" parameterType="string" resultType="ProcessFormEntity">
SELECT
id,
site,
bu,
request_id,
workflow_id,
node_id,
domain_control_account,
document_no,
document_type,
seq_no,
reject_flag,
reject_node_id,
is_remark,
classification_no,
step_id
FROM plm_process_form
WHERE site = #{site} and bu = #{bu} and request_id = #{requestId} and domain_control_account = #{domainControlAccount} and is_remark = 0
</select>
<select id="getNodeName" parameterType="string" resultType="string">
select
node_name
from plm_request_node
where site = #{site} and classification_no = #{classificationNo} and node_id = #{nodeId}
</select>
<select id="getNodeInformation" parameterType="com.spring.modules.change.vo.ChangeRequestVo" resultType="PlmRequestDetailEntity">
select
b.id,
b.site,
b.bu,
b.classification_no,
b.node_id,
b.node_name,
b.node_type,
b.remark,
b.workflow_id,
b.seq_no,
b.step_id
from plm_request_header as a
left join plm_request_node as b on a.site = b.site and a.bu = b.bu and a.classification_no = b.classification_no and a.workflow_id = b.workflow_id
where a.site = #{site} and a.menu_id = #{menuId} and a.status = 'Y' and b.step_id = #{stepId}
</select>
<select id="getNodeAuthority" parameterType="PlmRequestDetailEntity" resultType="RequestNodeAuthorityEntity">
select
a.site,
a.bu,
a.classification_no,
a.node_id,
a.node_name,
a.field_id,
a.update_flag,
a.table_id,
a.required,
b.fieldName
from plm_request_node_authority as a
left join (SELECT
col.name AS fieldId,
CONVERT(varchar(50), comm.value) AS fieldName,
tbl.name as tableId
FROM
sys.columns AS col
INNER JOIN
sys.tables AS tbl ON col.object_id = tbl.object_id
INNER JOIN
sys.types AS typ ON col.user_type_id = typ.user_type_id
LEFT JOIN
sys.extended_properties AS comm ON col.object_id = comm.major_id AND col.column_id = comm.minor_id) as b
on a.table_id = b.tableId and a.field_id = b.fieldId
where a.site = #{site} and a.bu = #{bu} and a.classification_no = #{classificationNo} and a.node_id = #{nodeId}
</select>
<!-- 编辑变更单属性 -->
<update id="updateStepId2" parameterType="ParamData">
update ${tableName}
set step_id = #{stepId}
<if test='rejectFlag == "Y"'>
,reject_flag = 'Y'
</if>
where site = #{site} and ${fieldName1} = #{docNo}
</update>
<!-- 编辑变更单属性 -->
<update id="updateProcessForm2" parameterType="ParamData">
update plm_process_form
set is_remark = 1,
update_date = getDate(),
update_by = #{userName}
where site = #{site} and document_no = #{docNo} and is_remark = 0
</update>
<!-- 编辑变更单属性 -->
<update id="updateChangeStatus2" parameterType="ParamData">
update ${tableName}
set ${fieldName2} = #{status},
update_date = getDate(),
update_by = #{userName},
step_id = #{stepId}
where site = #{site} and ${fieldName1} = #{docNo}
</update>
<!-- 编辑变更单的驳回标识 -->
<update id="updateChangeReject2" parameterType="ParamData">
update ${tableName}
set reject_flag = 'Y',
reject_step_id = #{rejectStepId}
where site = #{site} and ${fieldName1} = #{docNo}
</update>
<select id="queryNodeDetailLast" parameterType="string" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
SELECT
step_id
FROM plm_request_node
where site = #{site} and classification_no = #{classificationNo} and workflow_id = #{workflowId}
order by seq_no desc
</select>
<delete id="chooseItemDel">
delete from plm_change_item
where site = #{site} and change_no = #{changeNo}
</delete>
<delete id="chooseItemDel2">
delete from plm_change_FA_item
where site = #{site} and change_no = #{changeNo}
</delete>
<delete id="chooseItemCSDel">
delete from plm_change_countersignature_item
where site = #{site} and change_no = #{changeNo}
</delete>
<update id="updateProcessNode">
update plm_process_form
set node_conclusion = #{nodeConclusion},
reject_opinion = #{rejectOpinion}
where site = #{site} and bu = #{bu} and request_id = #{requestId} and classification_no = #{classificationNo} and node_id = #{nodeId}
</update>
<select id="getApprovalList" parameterType="com.spring.modules.change.vo.ProcessFormVo" resultType="com.spring.modules.change.vo.ProcessFormVo">
select
a.classification_no,
b.node_id,
b.node_name,
c.reject_flag,
case when c.reject_flag = 'Y' then '是' else '否' end as rejectFlagDesc,
c.reject_node_id,
dbo.plm_get_nodeName(a.site, c.reject_node_id, a.classification_no) as rejectNodeName,
c.node_conclusion,
case when c.node_conclusion = 'Y' then '同意' when c.node_conclusion = 'N' then '驳回' else '' end as nodeConclusionDesc,
c.create_date,
c.create_by,
c.reject_opinion
from plm_request_header a
LEFT JOIN plm_request_node b ON a.SITE = b.SITE AND a.classification_no = b.classification_no AND a.workflow_id = b.workflow_id
LEFT JOIN plm_process_form c ON b.SITE = b.SITE AND b.classification_no = c.classification_no AND b.workflow_id = c.workflow_id AND b.node_id = c.node_id and c.document_no = #{documentNo}
WHERE a.site = #{site} AND a.menu_id = #{menuId}
ORDER BY b.step_id ASC
</select>
<select id="getTechnicalSpecification" resultType="PlmTechnicalSpecificationSheetData">
SELECT
id,
site,
code_no,
rev_no,
ori_code_no
FROM plm_technical_specification_sheet
where site = #{site} and code_no = #{codeNo}
</select>
<update id="updatePartActive">
update part
set active = 'N'
where site = #{site} and part_no = #{partNo}
</update>
<select id="getBuBySite" parameterType="Bu" resultType="Bu">
SELECT
id,
site,
bu_no,
bu_desc,
remark
FROM BU
where site = #{site} and active = 'Y'
</select>
</mapper>