INSERT INTO plm_project_tool_applyHeader (site,apply_no,apply_by,status_code,status,apply_date,applySumQty,applyReason,remark,
create_by,create_date,department,quoter,tp,purchaser)
values
(#{site},#{applyNo},#{applyBy},#{statusCode},#{status},#{applyDate},#{applySumQty},#{applyReason},#{remark},#{createBy},
#{createDate},#{department},#{quoter},#{tp},#{purchaser})
INSERT INTO plm_project_tool_applyDetail (site,apply_no,seqNo,tool_id,standard_cost,applyQty,remark,orderRef1,orderRef2,orderRef3,orderRef4,orderRef5,orderRef6) values
(#{item.site},#{item.applyNo},#{item.seqNo},#{item.toolId},#{item.standardCost},#{item.applyQty},#{item.remark},#{item.orderRef1},
#{item.orderRef2},#{item.orderRef3},#{item.orderRef4},#{item.orderRef5},#{item.orderRef6})
update routing_tool set ApplyFlag='Y' from plm_project_tool_applyDetail b
where b.site=#{site} and b.apply_no=#{newApplyNo}
and routing_tool.site=b.Site and routing_tool.part_no=b.orderRef2 and CONVERT(varchar(20),routing_tool.routing_revision) =b.orderRef3 and
routing_tool.routing_type=b.orderRef4 and routing_tool.alternative_no=b.orderRef5
and CONVERT(varchar(20), routing_tool.operation_id)=b.orderRef6
update plm_project_tool_applyHeader
set status_code = #{statusCode},
status = #{status}
where site = #{site} and apply_no = #{applyNo}
delete from plm_project_tool_applyHeader where site=#{site} and apply_no=#{applyNo}
delete from plm_project_tool_applyDetail where site=#{site} and apply_no=#{applyNo}
update plm_project_tool_applyHeader set prNo=#{prNo},remark1=#{remark1},poNo=#{poNo},
allCost=#{allCost},remark2=#{remark2},supplierName=#{supplierName} where site=#{site} and apply_no=#{applyNo}
update plm_project_tool_applyHeader
set applySumQty = #{applySumQty},
applyReason = #{applyReason},
remark = #{remark},
tp=#{tp},
quoter=#{quoter},
purchaser=#{purchaser}
where site = #{site} and apply_no = #{applyNo}
update plm_project_tool_applyDetail set applyQty=#{applyQty} where site=#{site} and apply_no=#{applyNo} and seqNo=#{seqNo}