insert into eam_properties_item_available (ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType, site, bu_no)
values(#{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{site}, #{buNo})
update eam_properties_item_available
set AvailableValue = #{availableValue}
where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} and bu_no = #{buNo}
delete from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} and bu_no = #{buNo}
insert into eam_properties_model_header
(function_type, code_no, code_desc, active, created_date, created_by, delflag, version, update_date, update_by, site, bu_no, check_type)
values
(#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(), #{updateBy}, #{site}, #{buNo}, #{checkType})
update eam_properties_model_header
set version = version + 1,
code_desc = #{codeDesc},
active = #{active},
update_by = #{updateBy},
update_date = GetDate()
where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
delete from eam_properties_model_detail
where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
delete from eam_properties_model_header where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
insert into eam_properties_model_detail
(function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site,
bu_no, check_type, order_id)
values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site}, #{buNo}, #{checkType}, #{orderId})
delete from eam_properties_model_detail
where function_type = #{functionType} and code_no = #{codeNo} and properties_item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
update eam_workPlan_item
set DefaultValue = #{defaultValue},
ValueType = #{valueType},
ValueType_DB = #{valueTypeDb},
ValueChooseFlag = #{valueChooseFlag},
UpdateDate = GetDate(),
UpdateBy = #{createdBy},
MaxValue = #{maxValue,jdbcType=FLOAT},
MinValue = #{minValue,jdbcType=FLOAT},
ItemRemark = #{itemRemark}
where site = #{site} and planID = #{planID} and ItemType = #{itemType} and ItemNo = #{itemNo} and ObjectID = #{objectID} and bu_no = #{buNo}
update eam_workPlan_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
,ValueChooseFlag=#{valueChooseFlag},UpdateDate=GetDate(),UpdateBy=#{createdBy},MaxValue=null,MinValue=null,
ItemRemark=#{itemRemark}
where site=#{site} and planID=#{planID} and ItemType=#{itemType}
and ItemNo=#{itemNo}
insert into eam_workPlan_item_available
(Site, PlanID, ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType, ObjectID, bu_no)
values(#{site}, #{planID}, #{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{objectID}, #{buNo})
update eam_workPlan_item_available
set AvailableValue = #{availableValue},
updateBy = #{createdBy},
updateDate = GetDate()
where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} AND site = #{site} and planID = #{planID} and ObjectID = #{objectID} and bu_no = #{buNo}
delete from eam_workPlan_item_available
where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} AND site = #{site} and planID = #{planID} and ObjectID = #{objectID} and bu_no = #{buNo}
update eam_defect_feedBack
set Status = #{result},
FinishDate = GetDate(),
DefectID = #{defectID}
where Site = #{site} and FeedBackID = #{planID} and bu_no = #{buNo}
update eam_workOrder
set Status = '待确认',
ActualOperator = #{actualOperator},
ActualDate = #{actualDate},
Remark = #{remark},
disposal_measures = #{disposalMeasures},
WorkTime = CASE
WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) * 1.0 / 30) / 2)
END,
result = #{result,jdbcType=VARCHAR},
checkResult = #{checkResult},
handling_method = #{handlingMethod},
fault_reason = #{faultReason},
preventive_measure = #{preventiveMeasure}
where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
update eam_workOrder
set Status = '待审核',
ActualOperator = #{actualOperator},
reach_date = #{reachDate},
ActualDate = #{actualDate},
Remark = #{remark},
disposal_measures = #{disposalMeasures},
WorkTime = #{workTime},
result = #{result,jdbcType=VARCHAR},
checkResult = #{checkResult},
handling_method = #{handlingMethod},
check_remark = #{checkRemark}
where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
update eam_workOrder
set Status = '待审核',
ActualOperator = #{actualOperator},
ActualDate = #{actualDate},
Remark = #{remark},
disposal_measures = #{disposalMeasures},
WorkTime = CASE
WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) * 1.0 / 30) / 2)
END,
result = #{result,jdbcType=VARCHAR},
checkResult = #{checkResult},
handling_method = #{handlingMethod},
fault_reason = #{faultReason},
preventive_measure = #{preventiveMeasure}
where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
update eam_workOrder
set Status = '已完工',
ActualOperator = #{actualOperator},
ActualDate = GetDate(),
Remark = #{remark},
disposal_measures = #{disposalMeasures},
WorkTime = #{workTime},
result = #{result,jdbcType=VARCHAR},
checkResult = #{checkResult}
where site = #{site}
and orderNo = #{orderNo}
INSERT into eam_workOrder_item
(Site, bu_no, OrderNo, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, TextValue, NumberValue, CreatedDate, CreatedBy, FinishFlag, itemResult, item_notes)
values (#{site}, #{buNo}, #{orderNo}, #{itemNo}, #{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, #{valueChooseFlag}, #{maxValue,jdbcType=DOUBLE}, #{minValue,jdbcType=DOUBLE}, #{itemRemark,jdbcType=VARCHAR}, #{itemType}, #{textValue,jdbcType=VARCHAR}, #{numberValue,jdbcType=DOUBLE}, GetDate(), #{createdBy}, #{finishFlag}, #{itemResult}, #{itemNotes})
update eam_workPlan
set status = '已结束'
where site = #{site}
and PlanID = #{planID}
and ObjectID = #{objectID}
and GetDate() > PlanEndDate
update eam_workPlan_overview
set next_work_date = (select top 1 PlanDate from eam_workOrder where site = #{site} and bu_no = #{buNo} and PlanID = #{planID} and PlanDate > GetDate() and status = '未开工' order by PlanDate)
where site = #{site} and plan_id = #{planID} and bu_no = #{buNo}
update eam_workOrder
set Status = '已取消',
cancel_date = getDate(),
cancel_by = #{userId}
where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
update eam_workOrder
set Status = '已取消',
cancel_date = getDate(),
cancel_by = #{userId}
where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and Status = #{status} and bu_no = #{buNo}
update eam_workPlan
set Status = '已取消',
cancel_date = getDate(),
cancel_by = #{userId}
where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
update eam_workPlan
set Status = '已计划',
NextWorkDate = null
where site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
update eam_workPlan_overview
set status = '已取消',
next_work_date = null,
cancel_date = getDate(),
cancel_by = #{userId}
where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
update eam_workPlan
set Status = '已取消',
NextWorkDate = null,
cancel_date = getDate(),
cancel_by = #{userId}
where Site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
update eam_workOrder
set Status = '已取消',
cancel_date = getDate(),
cancel_by = #{userId}
where site = #{site} and PlanID = #{planID} and status = '未开工' and bu_no = #{buNo}
delete from eam_workOrder_item
where site = #{site} and bu_no = #{buNo}
and OrderNo in (select OrderNo from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 )
delete from eam_workOrder
where site = #{site} and bu_no = #{buNo}
and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1
update eam_workOrder
set PlanOperator = #{planOperator}
where site = #{site} and orderNo = #{orderNo}
INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
values(#{objectID},#{partNo},'',0,#{site})
delete from resource_spare where site = #{item.site} and resource_id = #{item.objectID}
INSERT INTO resource_spare
(resource_id, part_no, delflag, version, site)
select #{item.objectID}, part_no, delflag, 0, site from resource_spare where resource_id = #{item.oldObjectID} and site = #{item.site}
insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
ItemType) values(#{site},#{objectID},#{itemNo},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(),#{userId},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType})
update eam_object_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
,ValueChooseFlag=#{valueChooseFlag},MaxValue=#{maxValue,jdbcType=FLOAT},MinValue=#{minValue,jdbcType=FLOAT}
where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
and ItemNo=#{itemNo}
delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
and ItemNo=#{itemNo}
insert into eam_object_item_available (Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate() ,#{userId} from eam_properties_item_available
where ItemNo=#{itemNo} and ItemType=#{itemType}
delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
and ItemNo=#{itemNo}
insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
values(#{site},#{objectID},#{itemNo},#{itemType},#{valueNo},#{availableValue},GetDate(),#{createdBy})
update eam_object_item_available set AvailableValue=#{availableValue},updateDate=GetDate(),updateBy=#{createdBy}
where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
ItemType)
select #{site},#{objectID},ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,GetDate(),#{createBy},MaxValue,MinValue,ItemType
from eam_object_item where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate(),#{createBy}
from eam_object_item_available where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
delete from eam_object_defect where site=#{site} and objectID=#{objectID}
insert into eam_object_defect(site,ObjectID,DefectID,Active)
select #{site},#{objectID},DefectID,Active
from eam_object_defect where site=#{site} and objectID=#{oldObjectID}
update eam_defect_feedBack
set status = '已取消'
where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
update eam_defect_feedBack
set status = '已下达',
PlanOperator = #{planOperator},
UpdateDate = GetDate(),
UpdateBy = #{updateBy}
where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
INSERT INTO eam_workOrder
(Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy)
values(#{site}, #{buNo}, (select 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8) from eam_workOrder where site = #{site} and FunctionType='C' and bu_no = #{buNo}), #{feedBackID}, '', #{objectID}, '未开工', #{planOperator}, #{planDate}, 'C', GetDate(), #{userId})
delete from sys_oss where id = #{id}
UPDATE eam_workOrder
SET Status = '已完工'
WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
UPDATE eam_workOrder
SET Status = '待审核'
WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
UPDATE eam_workPlan_overview
SET status = '已结束'
WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
INSERT INTO eam_workPlan_overview
(site, plan_id, plan_desc, status, plan_start_date, plan_end_date, created_date, created_by, update_date, update_by,
remark, delete_flag, operator, operator_name, checker, checker_name, function_type, properties_code, plan_period,
work_order_rule, plan_cycle, task_start_date, plan_halt_date, auto_renewal, bu_no, check_type)
VALUES
(#{site}, #{planID}, #{planDesc}, '已计划', #{planStartDate}, #{planEndDate}, getDate(), #{createdBy}, getDate(), #{updateBy},
#{remark}, 'N', #{operator}, #{operatorName}, #{checker}, #{checkerName}, #{functionType}, #{propertiesCode}, #{planPeriod},
#{workOrderRule}, #{planCycle}, #{taskStartDate}, #{planHaltDate}, #{autoRenewal}, #{buNo}, #{checkType})
DELETE FROM eam_workPlan
WHERE Site = #{site}
AND PlanID = #{planID}
AND ObjectID = #{objectID}
INSERT INTO eam_workPlan
(Site,PlanID,PlanDesc,ObjectID,FunctionType,PropertiesCode,Operator,OperatorName,checker,checkerName,PlanPeriod,Status,PlanStartDate,PlanEndDate,CreatedDate,CreatedBy,Version,Remark,DeleteFlag)
values (#{site},#{planID},#{planDesc},#{objectID},#{functionType},#{propertiesCode},#{operator},#{operatorName},#{checker},#{checkerName},#{planPeriod},#{status},#{planStartDate},#{planEndDate},GetDate(),#{createdBy},0,#{remark},'N')
UPDATE eam_workPlan_overview
SET plan_desc = #{planDesc},
properties_code = #{propertiesCode},
plan_start_date = #{planStartDate},
plan_end_date = #{planEndDate},
plan_period = #{planPeriod},
remark = #{remark},
operator = #{operator},
operator_name = #{operatorName},
checker = #{checker},
checker_name = #{checkerName},
work_order_rule = #{workOrderRule},
task_start_date = #{taskStartDate},
plan_cycle = #{planCycle},
plan_halt_date = #{planHaltDate},
auto_renewal = #{autoRenewal}
WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
DELETE FROM eam_workPlan
WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
DELETE FROM eam_workPlan_item
WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
DELETE FROM eam_workPlan_item_available
WHERE Site = #{site}
AND PlanID = #{planID}
AND ObjectID = #{objectID}
UPDATE eam_workPlan_overview
SET status = '进行中',
next_work_date = plan_start_date
WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
INSERT INTO eam_actual_operator
(site, order_no, function_type, operator, bu_no)
VALUES (#{site}, #{orderNo}, #{functionType}, #{operator}, #{buNo})
INSERT INTO eam_workOrder
(Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no, document_source, repair_reporting_type, repair_type, PlanOperator)
VALUES
(#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo}, #{documentSource}, #{repairReportingType}, #{repairType}, #{planOperator})
INSERT INTO eam_workOrder
(Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{planOperator}, Dateadd(dd, Datediff(dd,0,Getdate()), 0), #{functionType}, getDate(), #{createBy}, #{checker}, #{planOperatorName}, #{checkerName})
UPDATE eam_workOrder
SET Status = #{status},
difficulty_level = #{difficultyLevel},
difficulty_remark = #{difficultyRemark}
WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
INSERT INTO eam_admin_dept
(Site, admin_id, dept_id)
VALUES (#{site}, #{adminID}, #{deptId})
DELETE FROM eam_admin_dept
WHERE site = #{site}
AND admin_id = #{adminID}
DELETE FROM sys_oss
WHERE id = #{id}
INSERT INTO eam_workOrder
(Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName, check_type)
VALUES
(#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{planStartDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName}, #{checkType})
INSERT INTO eam_workOrder
(Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName, last_execution_date, check_type)
VALUES
(#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{orderDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName}, #{lastExecutionDate}, #{checkType})
update eam_workPlan
set status = '进行中',
NextWorkDate = PlanStartDate
where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
DELETE FROM eam_workPlan_item
WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
DELETE FROM eam_workPlan_item_available
WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
INSERT INTO eam_workPlan_item (Site, bu_no, PlanID, ObjectID, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, CreatedDate, CreatedBy, image_flag, produce_control_flag)
select
#{site},
#{buNo},
#{planID},
#{objectID},
a.ItemNo,
a.ItemDesc,
case when c.site is not null then c.DefaultValue else a.DefaultValue end,
case when c.site is not null then c.ValueType else a.ValueType end,
case when c.site is not null then c.ValueType_DB else a.ValueType_DB end,
case when c.site is not null then c.ValueChooseFlag else a.ValueChooseFlag end,
case when c.site is not null then c.MaxValue else a.MaxValue end,
case when c.site is not null then c.MinValue else a.MinValue end,
a.ItemRemark,
a.ItemType,
GetDate(),
#{userId},
a.image_flag,
a.produce_control_flag
from eam_properties_item a
left join eam_properties_model_detail b on a.ItemType = b.function_type and a.ItemNo = b.properties_item_no and a.site = b.site and a.bu_no = b.bu_no
left join eam_object_item c on a.ItemType = c.ItemType and a.ItemNo = c.ItemNo and c.objectID = #{objectID}
where a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
INSERT INTO eam_workPlan_item_available (Site, bu_no, PlanID, ObjectID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy)
SELECT DISTINCT
#{site},
#{buNo},
#{planID},
#{objectID},
a.ItemNo,
a.ItemType,
case when c.ValueNo is not null then c.ValueNo else a.ValueNo end,
case when c.ValueNo is not null then c.AvailableValue else a.AvailableValue end,
GetDate(),
#{userId}
FROM eam_properties_item_available a
LEFT JOIN eam_properties_model_detail b on a.ItemType = b.function_type and a.ItemNo = b.properties_item_no and a.site = b.site and a.bu_no = b.bu_no
LEFT JOIN eam_object_item_available c on a.ItemNo = c.ItemNo and a.ItemType = c.ItemType and c.ObjectID = #{objectID}
WHERE a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
INSERT INTO eam_defect_feedBack
(Site, bu_no, FeedBackID, FeedBackDesc, ObjectID, DefectID, FunctionType, PlanOperator, Status, PlanDate,
Remark, deleteFlag, CreatedDate, CreatedBy, Version, DefectDate, urgency, repair_reporting_type, repair_type)
VALUES
(#{site}, #{buNo}, #{feedBackID}, #{feedBackDesc}, #{objectID}, #{defectID}, #{functionType}, #{planOperator}, #{status}, #{planDate},
#{remark}, #{deleteFlag}, getDate(), #{createdBy}, #{version}, #{defectDate}, #{urgency}, #{repairReportingType}, #{repairType})
UPDATE eam_defect_feedBack
SET Status = '已下达'
WHERE Site = #{site} and bu_no = #{buNo} and FeedBackID = #{feedBackID}
INSERT INTO eam_workOrder
(Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc, document_source, repair_reporting_type, repair_type, PlanOperator)
VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc}, #{documentSource}, #{repairReportingType}, #{repairType}, #{planOperator})
update eam_workOrder
set update_by = #{mesUser},
update_date = GetDate(),
Remark = #{remark},
reach_date = #{reachDate},
ActualDate = #{actualDate},
WorkTime = #{workTime},
disposal_measures = '',
disposal_measures = #{disposalMeasures},
checkResult = #{checkResult},
check_remark = #{checkRemark},
fault_reason = #{faultReason},
preventive_measure = #{preventiveMeasure}
where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
update eam_workOrder_item
set update_by = #{updateBy},
update_date = GetDate(),
TextValue = #{textValue},
NumberValue = #{numberValue},
itemResult = #{itemResult}
where site = #{site} and OrderNo = #{orderNo} and ItemNo = #{itemNo} and bu_no = #{buNo}
DELETE FROM eam_actual_operator
WHERE site = #{site} and order_no = #{orderNo} and function_type = #{functionType} and bu_no = #{buNo}
update eam_workOrder
set Status = #{status},
reach_date = GetDate(),
reach_operator = #{reachOperator},
reach_operator_name = #{reachOperatorName}
where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_No = #{buNo}
update eam_knowledge_base
SET defect_id = #{defectID},
defect_desc = #{defectDesc},
defect_describe = #{planDesc},
remark = #{remark},
fault_reason = #{faultReason},
handling_method = #{handlingMethod},
preventive_measure = #{preventiveMeasure},
feedback_by = #{feedbackBy},
actual_operator_name = #{actualOperatorName},
update_date = getDate(),
update_by = #{updateBy}
where site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
INSERT INTO eam_knowledge_base
(site, bu_no, num, defect_describe, remark, object_id, defect_id, defect_desc, order_no,
fault_reason, handling_method, preventive_measure, feedback_by, actual_operator_name, create_date, create_by)
VALUES
(#{site}, #{buNo}, #{num}, #{planDesc}, #{remark}, #{objectID}, #{defectID}, #{defectDesc}, #{orderNo},
#{faultReason}, #{handlingMethod}, #{preventiveMeasure}, #{feedbackBy}, #{actualOperatorName}, getDate(), #{updateBy})
UPDATE eam_defect_feedBack
SET Status = '已取消'
WHERE Site = #{site} AND FeedBackID = #{planID} and bu_no = #{buNo}
DELETE FROM eam_family
WHERE site = #{site} and bu_no = #{buNo} and FamilyID = #{familyID}
and son_id like #{sonId} + '%'
update eam_workOrder
set ActualDate = #{actualDate},
reach_date = #{reachDate},
fault_reason = #{faultReason},
handling_method = #{handlingMethod},
preventive_measure = #{preventiveMeasure},
Remark = #{remark},
WorkTime = #{workTime},
check_assessment = #{checkAssessment},
check_notes = #{checkNotes}
where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
INSERT INTO send_message_record (site, bu_no, plan_id, object_id, defect_id, feed_back_desc, sender, recipient, phone, send_date)
VALUES (#{site}, #{buNo}, #{planId}, #{objectId}, #{defectId}, #{feedBackDesc}, #{sender}, #{recipient}, #{phone}, getDate())
insert into eam_workOrder_coreComponents
(site, bu_no, OrderNo, ItemNo, partNo, oldSerialNo, newSerialNo, created_by, created_date)
values
(#{site}, #{buNo}, #{orderNo}, #{itemNo}, #{partNo}, #{oldSerialNo}, #{newSerialNo}, #{createdBy}, GetDate())
UPDATE eam_workOrder_coreComponents
SET oldSerialNo = #{oldSerialNo},
newSerialNo = #{newSerialNo}
WHERE site = #{site} and bu_no = #{buNo} and OrderNo = #{orderNo} and partNo = #{partNo}
INSERT INTO document_type_definition
(Site, document_type_id, document_type, responsible_department, estimated_completion_days,create_date, create_by)
VALUES
(#{site}, #{documentTypeId}, #{documentType}, #{responsibleDepartment}, #{estimatedCompletionDays}, getDate(), #{createBy})
UPDATE document_type_definition
SET document_type = #{documentType},
responsible_department = #{responsibleDepartment},
estimated_completion_days = #{estimatedCompletionDays},
update_date = getDate(),
update_by = #{updateBy}
WHERE Site = #{site} and document_type_id = #{documentTypeId}
DELETE FROM document_type_definition
WHERE Site = #{site} and document_type_id = #{documentTypeId}
INSERT INTO bu_document_list_definition
(Site, bu_no, project_category, document_type_id, project_phase,create_date, create_by)
VALUES
(#{site}, #{buNo}, #{projectCategory}, #{documentTypeId}, #{projectPhase},getDate(), #{createBy})
UPDATE bu_document_list_definition
SET project_phase = #{projectPhase},
project_category = #{projectCategory},
update_date = getDate(),
update_by = #{updateBy}
WHERE Site = #{site} and bu_no = #{buNo} and document_type_id = #{documentTypeId} and id = #{id}
DELETE FROM bu_document_list_definition
WHERE Site = #{site} and bu_no = #{buNo} and project_category = #{projectCategory} and document_type_id = #{documentTypeId} and project_phase = #{projectPhase}
delete from eam_workOrder_coreComponents
WHERE site = #{site} and bu_no = #{buNo} and OrderNo = #{orderNo} and partNo = #{partNo}
update eam_workOrder
set Status = '已取消'
where site = #{site} AND bu_no = #{buNo} AND OrderNo = #{orderNo} and FunctionType = #{functionType}
update inventory_stock
set in_qty = #{inQty},
out_qty = #{outQty},
qty_on_hand = #{qtyOnHand},
latest_out_date = getDate(),
latest_count_date = getDate()
site = #{site}
AND part_no = #{partNo}
AND batch_no = #{batchNo}
insert into repair_TransDetailsub
(TransNo, SeqNo, Site, itemNo, LocationID, BatchNo, RollQty, RollNo, orderRef2, orderRef4)
values
(#{transNo}, #{seqNo}, #{site}, #{itemNo}, #{locationId}, #{batchNo}, #{rollQty}, #{rollNo}, #{orderRef2}, #{orderRef4})
insert into inventory_stock
(site, warehouse_id, part_no, first_in_date, latest_out_date, latest_in_date, active_date, in_qty, out_qty, qty_on_hand, citem_code, partner_id, latest_count_date, location_id, batch_no)
values
(#{site}, #{warehouseId}, #{partNo}, #{firstInDate}, getDate(), getDate(),getDate(), #{inQty}, #{outQty}, #{qtyOnHand}, #{citemCode}, #{partnerId}, #{latestCountDate}, #{locationId}, #{batchNo})
insert into repair_TransDetail
(TransNo, Site, ItemNo, PartNo, LocationID, TransQty, Direction, BatchNo, OrderRef1, OrderRef2, OrderRef3, citem_code)
values
(#{transNo}, #{site}, #{itemNo}, #{partNo}, #{locationId}, #{transQty}, #{direction}, #{batchNo}, #{orderRef1}, #{orderRef2}, #{orderRef3}, #{citemCode})
insert into repair_TransHeader
(TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, TransferFlag, EnterDate, UseLocation, LinkOrderFlag, Status, Remark, orderRef1)
values
(#{transNo}, #{site}, #{warehouseId}, #{transDate}, #{transTypeDb}, #{transType}, #{userName}, #{receiver}, #{transYear}, #{transMonth}, #{partnerId}, #{partnerType}, #{authorizeFlag}, #{transferFlag}, getDate(), #{useLocation}, #{linkOrderFlag}, #{status}, #{remark}, #{orderRef1})
update part_spare
set last_update_by =#{userName},
location_id = #{locationId},
warehouse_id = #{warehouseId}
where site = #{site} and part_no = #{partNo}
update eam_workOrder
set Status = #{status},
confirm_by = #{confirmBy},
confirm_date = getDate(),
confirm_result = #{confirmResult},
confirm_count = #{confirmCount},
confirm_assessment = #{confirmAssessment},
confirm_remark = #{confirmRemark}
where site = #{site} AND bu_no = #{buNo} AND OrderNo = #{orderNo} and FunctionType = #{functionType}
update eam_defect_feedBack
set Status = #{status}
where site = #{site} AND bu_no = #{buNo} AND FeedBackID = #{planID} and FunctionType = #{functionType}
update eam_workOrder
set Status = '已完工'
where site = #{site} and bu_no = #{buNo} and orderNo = #{orderNo} and FunctionType = #{functionType}
update TPM_Message_Notification
set send_flag = 'N'
WHERE SITE = #{site} AND bu_no = #{buNo} AND plan_no = #{feedBackId} AND order_no = #{orderNo}
UPDATE eam_workOrder
SET repair_type = #{repairType}
WHERE site = #{site} AND bu_no = #{buNo} AND OrderNo = #{orderNo}
update eam_properties_model_detail
set order_id=#{orderId}
where site = #{site}
and bu_no= #{buNo}
and properties_item_no = #{itemNo}
and code_no = #{codeNo}
and function_type = #{functionType}
update TPM_Message_Notification
set send_flag = 'N'
WHERE SITE = #{site} AND bu_no = #{buNo} AND plan_no = #{planID} AND order_no = #{orderNo}
UPDATE eam_workOrder
SET is_return = 'Y'
WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
UPDATE eam_workOrder
SET is_return = 'N'
WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
update eam_workOrder
set Remark = #{remark},
handling_method = #{handlingMethod},
fault_reason = #{faultReason},
preventive_measure = #{preventiveMeasure},
is_return = 'N',
status = '待审核'
where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
update eam_defect_feedBack
set PlanOperator = #{planOperator}
where site = #{site} and bu_no = #{buNo} and feedBackID = #{feedBackID}
UPDATE eam_workOrder
SET Status = '已到达',
is_return = 'Y'
WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}