delete from sys_oss
where order_ref1 = #{site} and order_ref2 = #{changeNo}
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
(#{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})
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 (
#{item}
)
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 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})
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}
insert into plm_change_ecn_type_detail
(site, change_no, header_value, value, flag) VALUES
(#{item.site}, #{item.changeNo}, #{item.headerValue}, #{item.value}, #{item.flag})
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
(#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=TIMESTAMP}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo})
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
(#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=TIMESTAMP}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo}, #{item.chooseValue})
delete from plm_change_request_detail
where site = #{site} and change_no = #{changeNo} and code_no = #{codeNo}
delete from plm_change_request_detail
where site = #{site} and change_no = #{changeNo}
delete from plm_change_ecn_type_detail
where site = #{site} and change_no = #{changeNo}
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 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 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 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}
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
(#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=TIMESTAMP}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo})
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, process_intervention_flag)
VALUES
(#{site}, #{bu}, #{requestId}, #{workflowId}, #{nodeId}, #{domainControlAccount}, #{documentNo}, #{documentType}, #{seqNo}, #{rejectFlag}, #{rejectNodeId}, #{nodeConclusion}, #{submitDate}, #{submittedBy}, getDate(), #{createBy}, #{isRemark}, #{classificationNo}, #{stepId}, #{menuId}, #{processInterventionFlag})
update plm_change_request
set change_status = #{changeStatus},
update_date = getDate(),
update_by = #{userName}
where site = #{site} and change_no = #{changeNo}
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 plm_change_request
set step_id = #{stepId}
reject_flag = 'Y',
where site = #{site} and change_no = #{changeNo}
update plm_change_request
set reject_flag = 'Y',
reject_step_id = #{rejectStepId}
where site = #{site} and change_no = #{changeNo}
update plm_process_form
set reject_flag = 'Y'
where site = #{site} and bu = #{bu} and request_id = #{requestId} and is_remark = 0
update ${tableName}
set step_id = #{stepId}
,reject_flag = 'Y'
site = #{site} and ${fieldName1} = #{docNo}
AND rev_no = #{revisionNo}
update ${tableName}
set
${fieldName2} = 'spz'
${fieldName2} = '审批中'
site = #{site} and ${fieldName1} = #{docNo}
AND rev_no = #{revisionNo}
update a
set A.is_remark = 1,
A.update_date = getDate(),
A.update_by = #{userName}
from plm_process_form a
left join sys_user b on a.domain_control_account = B.domain_control_account
where A.site = #{site} and document_no = #{docNo} and is_remark = 0 AND B.username = #{userName}
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 ${tableName}
set ${fieldName2} = #{status},
update_date = getDate(),
update_by = #{userName},
step_id = #{stepId}
site = #{site} and ${fieldName1} = #{docNo}
AND rev_no = #{revisionNo}
update ${tableName}
set reject_flag = 'Y',
reject_step_id = #{rejectStepId}
where site = #{site} and ${fieldName1} = #{docNo}
delete from plm_change_item
where site = #{site} and change_no = #{changeNo}
delete from plm_change_FA_item
where site = #{site} and change_no = #{changeNo}
delete from plm_change_countersignature_item
where site = #{site} and change_no = #{changeNo}
delete from plm_change_cost_impact
where site = #{site} and change_no = #{changeNo}
delete from plm_change_execution_info
where site = #{site} and change_no = #{changeNo}
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}
and domain_control_account = #{domainControlAccount}
and (node_conclusion is null or node_conclusion = '')
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}
and (node_conclusion is null or node_conclusion = '')
update part
set active = 'N'
where site = #{site} and part_no = #{partNo}
update plm_process_form
set node_conclusion = 'Y',
update_date = getDate(),
update_by = #{userName}
where site = #{site} and bu = #{bu} and menu_id = #{menuId} and document_no = #{docNo} and step_id = #{stepId}
insert into plm_process_form (site, bu, request_id, workflow_id, node_id, domain_control_account, document_no, document_type, classification_no,
seq_no, node_conclusion, is_remark, step_id, menu_id, create_by, create_date, update_by, update_date)
SELECT
TOP 1
a.site,
a.bu,
a.request_id,
a.workflow_id,
b.node_id,
domain_control_account,
document_no,
a.document_type,
A.classification_no,
a.seq_no + 10 AS seq_no,
'Y' AS node_conclusion,
'1' AS is_remark,
b.step_id,
A.menu_id,
a.create_by,
a.create_date,
a.update_by,
a.update_date
FROM
plm_process_form A
LEFT JOIN (
SELECT
TOP 1
SITE,
classification_no,
node_id,
node_name,
step_id
FROM plm_request_node
WHERE SITE = #{site} AND classification_no = #{classificationNo}
ORDER BY step_id DESC
) B ON A.site = B.site AND A.classification_no = B.classification_no
WHERE A.site = #{site} AND document_no = #{docNo} AND a.classification_no IS NOT NULL
ORDER BY A.ID DESC
update plm_technical_specification_sheet
set show_in_query_flag = #{showInQueryFlag}
where site = #{site} and code_no = #{codeNo}