UPDATE calendar set CalendarDesc=#{calendarDesc},status=#{status} WHERE CalendarID = #{calendarId} AND site = #{site} INSERT INTO calendar(site, calendarID, calendarDesc, status) VALUES (#{site}, #{calendarId}, #{calendarDesc}, #{status}) DELETE FROM calendar WHERE CalendarID = #{calendarId} AND site = #{site} UPDATE calendar_datetype_shift set shiftdesc=#{shiftdesc},startexacttime=#{startexacttime} ,endexacttime=#{endexacttime},starttime=#{starttime},endtime=#{endtime} AND site = #{site} AND DateType = #{datetype} and ShiftNo =#{shiftno} INSERT INTO calendar_datetype_shift (shiftno, datetype, site, shiftdesc, startexacttime, endexacttime, starttime, endtime) VALUES (#{shiftno}, #{datetype}, #{site}, #{shiftdesc}, #{startexacttime}, #{endexacttime}, #{starttime}, #{endtime}) INSERT INTO calendar_datetype (site, datetype, excepttime1, exceptduration1, excepttime2, exceptduration2, excepttime3, exceptduration3, excepttime4, exceptduration4, excepttime5, exceptduration5, excepttime6, exceptduration6, worktime, remark, exceptexacttime1, exceptexacttime2, exceptexacttime3, exceptexacttime4, exceptexacttime5, exceptexacttime6) VALUES (#{site}, #{datetype}, #{excepttime1}, #{exceptduration1}, #{excepttime2}, #{exceptduration2}, #{excepttime3}, #{exceptduration3}, #{excepttime4}, #{exceptduration4}, #{excepttime5}, #{exceptduration5}, #{excepttime6}, #{exceptduration6}, #{worktime}, #{remark}, #{exceptexacttime1}, #{exceptexacttime2}, #{exceptexacttime3}, #{exceptexacttime4}, #{exceptexacttime5}, #{exceptexacttime6}) DELETE FROM calendar_datetype WHERE site = #{site} and datetype = #{datetype} DELETE FROM calendar_exception_shift WHERE site = #{site} AND CalendarId = #{calendarId} AND ScheduleDate = #{scheduledate} INSERT INTO calendar_exception ( site, CalendarID, scheduledate, excepttime1, exceptduration1, excepttime2 , exceptduration2, excepttime3 , exceptduration3, excepttime4, exceptduration4, excepttime5, exceptduration5 , excepttime6, exceptduration6, worktime, datetype, exceptexacttime1 , exceptexacttime2, exceptexacttime3, exceptexacttime4, exceptexacttime5 , exceptexacttime6) VALUES (#{site}, #{calendarId}, #{scheduledate}, #{excepttime1}, #{exceptduration1}, #{excepttime2}, #{exceptduration2}, #{excepttime3}, #{exceptduration3}, #{excepttime4}, #{exceptduration4}, #{excepttime5}, #{exceptduration5}, #{excepttime6}, #{exceptduration6}, #{worktime}, #{datetype}, #{exceptexacttime1} , #{exceptexacttime2}, #{exceptexacttime3}, #{exceptexacttime4}, #{exceptexacttime5}, #{exceptexacttime6}) INSERT INTO calendar_exception_shift (site, calendarID, shiftno, scheduledate, shiftdesc, startexacttime, endexacttime, starttime, endtime) VALUES (#{site}, #{calendarId}, #{shiftno}, #{scheduledate}, #{shiftdesc}, #{startexacttime}, #{endexacttime}, #{starttime}, #{endtime}) DELETE FROM calendar_exception WHERE site = #{site} and CalendarId = #{calendarId} AND scheduledate = #{scheduledate} UPDATE calendar_datetype set excepttime1=#{excepttime1},exceptduration1=#{exceptduration1}, excepttime2=#{excepttime2},exceptduration2=#{exceptduration2},excepttime3=#{excepttime3},exceptduration3=#{exceptduration3},excepttime4=#{excepttime4},exceptduration4=#{exceptduration4}, excepttime5=#{excepttime5},exceptduration5=#{exceptduration5},excepttime6=#{excepttime6},exceptduration6=#{exceptduration6},worktime=#{worktime},remark=#{remark},exceptexacttime1=#{exceptexacttime1}, exceptexacttime2=#{exceptexacttime2},exceptexacttime3=#{exceptexacttime3},exceptexacttime4=#{exceptexacttime4},exceptexacttime5=#{exceptexacttime5},exceptexacttime6=#{exceptexacttime6} AND site = #{site} AND datetype = #{datetype} DELETE FROM calendar_datetype_shift WHERE shiftno = #{shiftno} AND site = #{site} AND DateType = #{datetype} INSERT INTO WorkCenterResource (Site, WorkCenterNo, ResourceID, ResourceDesc, Efficiency, Utilization, Active, Remark, CreatedDate, CalendarID, VirturlFlag) VALUES (#{site}, #{workCenterNo}, #{resourceID}, #{resourceDesc}, #{efficiency}, #{utilization}, #{active}, #{remark}, GetDate(), #{calendarID}, 'N') update WorkCenterResource SET ResourceDesc=#{resourceDesc}, Efficiency=#{efficiency}, Utilization=#{utilization}, Active=#{active}, Remark=#{remark}, CalendarID=#{calendarID} where Site = #{site} and ResourceID = #{resourceID} INSERT INTO Site (SiteID, SiteName, SiteName_E, Address, Address_E, ContactName, PostCode, Email, FaxNo, PhoneNo, Active, Website, CompanyID, ShipTime, ReferenceCustomerID) VALUES (#{siteID}, #{siteName}, #{siteNameE}, #{address}, #{addressE}, #{contactName}, #{postCode}, #{email}, #{faxNo}, #{phoneNo}, #{active}, #{website}, #{companyID}, #{shipTime}, #{referenceCustomerID}) update Site SET SiteName=#{siteName}, SiteName_E=#{siteNameE}, Address=#{address}, Address_E=#{addressE}, ContactName=#{contactName}, PostCode=#{postCode}, Email=#{email}, FaxNo=#{faxNo}, PhoneNo=#{phoneNo}, Active=#{active}, Website=#{website}, CompanyID=#{companyID}, ShipTime=#{shipTime}, ReferenceCustomerID=#{referenceCustomerID} where SiteID = #{siteID} INSERT INTO PartFamily (FamilyID, Site, FamilyName, Active, CheckPercentage, InspectFlag) values (#{familyID}, #{site}, #{familyName}, #{active}, #{checkPercentage}, #{inspectFlag}) UPDATE PartFamily SET Site=#{site}, FamilyName=#{familyName}, Active=#{active}, CheckPercentage=#{checkPercentage}, InspectFlag=#{inspectFlag} where FamilyID = #{familyID} and Site = #{site} delete from PartFamily where FamilyID = #{familyID} and Site = #{site} INSERT INTO UM (UMID, Site, UMName, Active) values (#{umid}, #{site}, #{uMName}, #{active}) UPDATE UM SET Site=#{site}, UMName=#{uMName}, Active=#{active} where UMID = #{umid} and Site = #{site} delete from UM where UMID = #{umid} and Site = #{site} INSERT INTO DowntimeReason (Site, ReasonCode, Area, ReasonDescription, Active) values (#{site}, #{reasonCode}, #{area}, #{reasonDescription}, #{active}) UPDATE DowntimeReason SET Active=#{active}, Area=#{area}, ReasonDescription=#{reasonDescription} where ReasonCode = #{reasonCode} and Site = #{site} delete from DowntimeReason where ReasonCode = #{reasonCode} and Site = #{site} INSERT INTO ReferencePartInfo (Site, CustomerID, PartNo, ReferencePartDesc, SupplierID, FGPartNo, LastUpdateBy) values (#{site}, #{customerID}, #{partNo}, #{referencePartDesc}, #{supplierID}, #{fGPartNo}, #{user}) UPDATE ReferencePartInfo SET Site=#{site}, CustomerID=#{customerID}, PartNo=#{partNo}, ReferencePartDesc=#{referencePartDesc}, SupplierID=#{supplierID}, FGPartNo=#{fGPartNo}, LastUpdateBy=#{user} where CustomerID = #{customerID} and Site = #{site} and FGPartNo = #{fGPartNo} and PartNo = #{partNo} delete from ReferencePartInfo where CustomerID = #{customerID} and Site = #{site} and FGPartNo = #{fGPartNo} and PartNo = #{partNo} INSERT INTO ProductionLine (Site, ProLineNo, ProLineDesc, Active, CreatedDate) values (#{site}, #{proLineNo}, #{proLineDesc}, #{active}, #{createdDate}) UPDATE ProductionLine SET ProLineDesc=#{proLineDesc}, Active=#{active}, CreatedDate=#{createdDate} where ProLineNo = #{proLineNo} and Site = #{site} delete from ProductionLine where ProLineNo = #{proLineNo} and Site = #{site} INSERT INTO WorkCenter (Site, WorkCenterNo, WorkCenterDesc, WorkCenterType_DB, WorkCenterType, AverageCapacity, Efficiency, Utilization, CapacityType_DB, CapacityType, UMID, Active, Remark, CreatedDate, ProLineNo, CanCreateNewRollFlag, NeedSetupFlag) values (#{site}, #{workCenterNo}, #{workCenterDesc}, #{workCenterTypeDb}, #{workCenterType}, 0, 100, 100, 'I', '无限能力', #{umid}, #{active}, #{remark}, #{createdDate}, #{proLineNo}, #{canCreateNewRollFlag}, #{needSetupFlag}) UPDATE WorkCenter SET WorkCenterDesc=#{workCenterDesc}, Active=#{active}, WorkCenterType=#{workCenterNo}, WorkCenterType_DB=#{workCenterTypeDb}, Remark=#{remark}, CreatedDate=#{createdDate}, ProLineNo=#{proLineNo}, CanCreateNewRollFlag=#{canCreateNewRollFlag}, NeedSetupFlag=#{needSetupFlag} where WorkCenterNo = #{workCenterNo} and Site = #{site} delete from WorkCenter where WorkCenterNo = #{workCenterNo} and Site = #{site} delete from WorkCenterResource where ResourceID = #{resourceID} and Site = #{site} UPDATE WorkCenterResource SET VirturlFlag=#{virturlFlag} where ResourceID = #{resourceID} and Site = #{site} INSERT INTO Company (CompanyID, CompanyName, Active, TaxNo, BankName, BankAccount, CutoffDate_DB, CutoffDate, CutoffDate_FixDate) values (#{companyID}, #{companyName}, #{active}, #{taxNo}, #{bankName}, #{bankAccount}, #{cutoffDateDb}, #{cutoffDate}, #{cutoffDateFixDate}) UPDATE Company SET CompanyName=#{companyName}, CutoffDate_DB=#{cutoffDateDb}, Active=#{active}, TaxNo=#{taxNo}, BankName=#{bankName}, BankAccount=#{bankAccount}, CutoffDate=#{cutoffDate}, CutoffDate_FixDate=#{cutoffDateFixDate} where CompanyID = #{companyID} delete from Company where CompanyID = #{companyID} insert into RoutingDetail (Site, PartNo, RevNo, ItemNo, OperationDesc, WorkCenterNo, MachSetupTime, MachRunFactor, FactorUnit_DB, FactorUnit, Efficiency, Crewsize, JJGZ_UnitFactor_DB, JJGZ_UnitFactor, JJGZ_UnitPrice, Remark, WX_UnitCost, BatchQty) VALUES (#{site}, #{partNo}, #{revNo}, #{itemNo}, #{operationDesc}, #{workCenterNo}, #{machSetupTime}, #{machRunFactor}, #{factorUnitDb}, #{factorUnit}, #{efficiency}, #{crewsize}, #{jjgzUnitFactorDb}, #{jjgzUnitFactor}, #{jjgzUnitPrice}, #{remark}, 0, 0) UPDATE RoutingDetail OperationDesc=#{operationDesc}, WorkCenterNo=#{workCenterNo}, MachSetupTime=#{machSetupTime}, MachRunFactor=#{machRunFactor}, FactorUnit_DB=#{factorUnitDb}, FactorUnit=#{factorUnit}, Efficiency=#{efficiency}, Crewsize=#{crewsize}, JJGZ_UnitFactor_DB=#{jjgzUnitFactorDb}, JJGZ_UnitFactor=#{jjgzUnitFactor}, JJGZ_UnitPrice=#{jjgzUnitPrice}, Remark=#{remark} WHERE partNo = #{partNo} and site = #{site} and revNo = #{revNo} and ItemNo = #{itemNo} delete from RoutingDetail where site = #{site} and PartNo = #{partNo} and RevNo = #{revNo} and ItemNo = #{itemNo} INSERT INTO RoutingDetail_AvailableResource(Site, PartNo, RevNo, ItemNo, ResourceID) VALUES (#{site}, #{partNo}, #{revNo}, #{itemNo}, #{resourceID}) delete from RoutingDetail_AvailableResource where site = #{site} and PartNo = #{partNo} and revNo = #{revNo} and itemNo = #{itemNo} and ResourceID = #{resourceID} INSERT INTO RoutingTool(Site, PartNo, RevNo, ItemNo, ToolID, ToolQty, Remark, CreateDate, CreatedBy) VALUES (#{site}, #{partNo}, #{revNo}, #{itemNo}, #{newToolId}, #{toolQty}, #{remark}, GETDATE(), #{user}) update RoutingTool SET ToolQty=#{toolQty}, Remark=#{remark}, ToolID = #{newToolId} WHERE Site = #{site} and PartNo = #{partNo} and ToolID = #{toolID} and RevNo = #{revNo} and ItemNo = #{itemNo} delete from RoutingTool WHERE Site = #{site} and PartNo = #{partNo} and ToolID = #{toolID} and RevNo = #{revNo} and ItemNo = #{itemNo} update RoutingHeader SET status=#{status}, status_DB=#{statusDb}, PhaseOutDate=#{phaseOutDate} where Site = #{site} and PartNo = #{partNo} and RevNo = #{revNo} Select Site, OrderNo, LotSize into ${tableName} from ShopOrder as T where Site = #{site} and PartNo = #{partNo} and (Status = '已计划' or Status = '已下达') and Not exists(Select 1 from SOScheduledRouting as D Where T.Site = D.Site and T.OrderNo = D.OrderNo) and T.OrderType != 'P' Update ShopOrder Set RoutingRevNo=#{revNo} from ${tableName} as T where ShopOrder.Site = T.Site and ShopOrder.OrderNo = T.OrderNo Delete SORouting from ${tableName} as T where SORouting.Site = T.Site and SORouting.OrderNo = T.OrderNo Delete SOTool from ${tableName} as T where SOTool.Site = T.Site and SOTool.OrderNo = T.OrderNo Insert into SORouting( Site, OrderNo, ItemNo, OperationDesc, WorkCenterNo, MachSetupTime, MachRunFactor , FactorUnit_DB, FactorUnit, TimeRequired, TimeReported, Efficiency, Remark, QtyRequired , QtyReported, QtyApprove , PlanStartTime, PlanFinishTime, BarcodeID, PartNo, ClosedFlag, OutWorkFlag, OutWorkPartNo , QtyOnPR, QtyOnPO, QtyScrapt, Crewsize , PreItemNo, NextItemNo, ScheduledFlag, QtyScheduled) Select T.Site , D.OrderNo , ItemNo , OperationDesc , WorkCenterNo , MachSetupTime , MachRunFactor , FactorUnit_DB , FactorUnit , (MachSetupTime + (Case when MachRunFactor = 0 then 0 else (Case when FactorUnit_DB = '1' then D.LotSize / MachRunFactor when FactorUnit_DB = '2' then D.LotSize * MachRunFactor when FactorUnit_DB = '3' then MachRunFactor end) end) / (Efficiency / 100)) as TimeRequired , 0 , Efficiency , Remark , D.LotSize , 0 , 0 , 0 , 0 , (Case when len(OrderNo) > 10 then D.Site + '-' + D.OrderNo + '-' + dbo.Get_PadL(ItemNo, 4, '0') else D.Site + '-' + dbo.Get_PadL(D.OrderNo, 10, '0') + '-' + dbo.Get_PadL(ItemNo, 4, '0') end) , T.PartNo , 'N' , (Case when dbo.Get_WorkCenter_TypeDB(T.Site, WorkCenterNo) = 'O' then 'Y' else 'N' end) as OutWorkFlag , WX_PartNo as OutWorkPartNo , 0.0 as QtyOnPR , 0.0 as QtyOnPO , 0.0 as QtyScrapt , Crewsize , Isnull((Select Max(D.ItemNo) as PreItemNo from RoutingDetail as D Where D.Site = T.Site and D.PartNo = T.PartNo and D.RevNo = T.RevNo and T.ItemNo > D.ItemNo), 0) , Isnull((Select Min(D.ItemNo) as NextItemNo from RoutingDetail as D Where D.Site = T.Site and D.PartNo = T.PartNo and D.RevNo = T.RevNo and D.ItemNo > T.ItemNo), 0) , 'N' , 0 from RoutingDetail as T, ${tableName} as D Where D.Site = T.Site and T.site = #{site} and T.PartNo = #{partNo} and T.RevNo = #{revNo} Insert into SOTool(Site, OrderNo, ItemNo, ToolID, ToolQty, Remark, CreateDate, CreatedBy) Select T.Site, D.OrderNo, ItemNo, ToolID, ToolQty, Remark, getdate(), #{user} from RoutingTool as T, ${tableName} as D Where D.Site = T.Site and T.site = #{site} and T.PartNo = #{partNo} and T.RevNo = #{revNo} Drop table ${tableName} Insert into RoutingHeader(Site, PartNo, RevNo, PhaseInDate, PhaseOutDate, RoutingType_DB, RoutingType, Status, Status_DB, Remark, Defaultflag, RepairFlag) Select Site, #{partNo1}, #{revNo1}, #{phaseInDate1}, null, RoutingType_DB, RoutingType, '试验', 'T', '', #{oldFlag1}, #{repairFlag1} FROM RoutingHeader where Site = #{site} and PartNo = #{partNo} and RevNo = #{revNo} Insert into RoutingDetail(Site, PartNo, RevNo, ItemNo, OperationDesc, WorkCenterNo, MachSetupTime, MachRunFactor, FactorUnit_DB, FactorUnit, Efficiency, Crewsize, Remark, WX_PartNo, WX_UnitCost) Select Site, #{partNo1}, #{revNo1}, ItemNo, OperationDesc, WorkCenterNo, MachSetupTime, MachRunFactor, FactorUnit_DB, FactorUnit, Efficiency, Crewsize, Remark, WX_PartNo, WX_UnitCost from RoutingDetail where Site = #{site} and PartNo = #{partNo} and RevNo = #{revNo} Insert into RoutingTool(Site, PartNo, RevNo, ItemNo, ToolID, ToolQty, Remark, CreateDate, CreatedBy) Select Site, #{partNo1}, #{revNo1}, ItemNo, ToolID, ToolQty, Remark, getdate(), #{user} from RoutingTool where Site = #{site} and PartNo = #{partNo} and RevNo = #{revNo} Insert into RoutingDetail_AvailableResource(Site, PartNo, RevNo, ItemNo, ResourceID) Select Site, #{partNo1}, #{revNo1}, ItemNo, ResourceID from RoutingDetail_AvailableResource as T where T.Site = #{site} and T.PartNo = #{partNo} and T.RevNo = #{revNo} Update RoutingHeader Set PhaseOutDate=(Case when Status_DB != 'S' then #{phaseInDate1} else PhaseOutDate end), Status_DB='S', Status='停用', DefaultFlag='N' where Site = #{site} and PartNo = #{partNo1} and RevNo = #{revNo} update RoutingHeader set Defaultflag = case when RevNo = #{revNo} then 'Y' else 'N' end where Site = #{site} and PartNo = #{partNo} insert into RoutingHeader(Site, PartNo, RevNo, PhaseInDate, PhaseOutDate, RoutingType_DB, RoutingType, Status, Status_DB, Defaultflag, Remark, RepairFlag) VALUES (#{site}, #{partNo}, #{revNo}, #{phaseInDate}, #{phaseOutDate}, #{routingTypeDb}, #{routingType}, #{status}, #{statusDb}, #{defaultflag}, #{remark}, #{repairFlag}) update RoutingHeader SET PhaseInDate=#{phaseInDate}, PhaseOutDate=#{phaseOutDate}, Remark=#{remark}, RepairFlag=#{repairFlag} where Site = #{site} and PartNo = #{partNo} and RevNo = #{revNo} update RoutingHeader set Defaultflag = 'N' where Site = #{site} and PartNo = #{partNo} DELETE FROM RoutingHeader where Site = #{site} and PartNo = #{partNo} and RevNo = #{revNo} DELETE FROM RoutingDetail where Site = #{site} and PartNo = #{partNo} and RevNo = #{revNo} DELETE FROM RoutingTool where Site = #{site} and PartNo = #{partNo} and RevNo = #{revNo} DELETE FROM RoutingDetail_AvailableResource where Site = #{site} and PartNo = #{partNo} and RevNo = #{revNo} UPDATE Calendar_Exception_Shift set startexacttime=#{startexacttime} , endexacttime=#{endexacttime} , starttime=#{starttime} , endtime=#{endtime} where site = #{site} and CalendarID = #{calendarId} and ScheduleDate = #{scheduledate} and ShiftNo = #{shiftno} insert into SORouting(Site, OrderNo, ItemNo, OperationDesc, WorkCenterNo, MachSetupTime, MachRunFactor, FactorUnit_DB, FactorUnit, QtyRequired, QtyReported, QtyApprove, TimeRequired, TimeReported, Efficiency, PlanStartTime, PlanFinishTime, BarcodeID, Remark, PartNo, Crewsize, ClosedFlag, QtyScrapt, OutWorkFlag, OutWorkPartNo, QtyOnPR, QtyOnPO, PreItemNo, NextItemNo, ScheduledFlag, QtyScheduled) values (#{site}, #{orderNo}, #{itemNo}, #{operationDesc}, #{workCenterNo}, #{machSetupTime}, #{machRunFactor}, #{factorUnitDb}, #{factorUnit}, #{lotSize}, 0, 0, dbo.Get_Routing_TimeRequired(#{site}, #{lotSize}, #{machSetupTime}, #{machRunFactor}, #{factorUnit}, #{efficiency}), 0, #{efficiency}, #{planStartTime}, #{planFinishTime}, #{barcodeID}, #{remark}, #{partNo}, #{crewsize}, 'N', 0, 'N', '', 0, 0, #{preItemNo}, 0, 'N', 0) update SORouting SET OperationDesc=#{operationDesc}, WorkCenterNo=#{workCenterNo}, MachSetupTime=#{machSetupTime}, FactorUnit_DB=#{factorUnitDb}, FactorUnit=#{factorUnit}, MachRunFactor=#{machRunFactor}, PlanStartTime=#{planStartTime}, PlanFinishTime=#{planFinishTime}, Efficiency=#{efficiency}, Crewsize=#{crewsize}, Remark=#{remark}, TimeRequired=dbo.Get_Routing_TimeRequired(#{site}, #{lotSize}, #{machSetupTime}, #{machRunFactor}, #{factorUnit}, #{efficiency}) where OrderNo = #{orderNo} and site = #{site} and ItemNo = #{itemNo} update SORouting SET NextItemNo=#{itemNo} where OrderNo = #{orderNo} and site = #{site} and ItemNo = #{preItemNo} insert into SORouting_AvailableResource(Site, OrderNo, ItemNo, ResourceID) values (#{site}, #{orderNo}, #{itemNo}, #{resourceID}) delete from SORouting_AvailableResource where site = #{site} and orderNo = #{orderNo} and ItemNo = #{itemNo} and ResourceID = #{resourceID} DELETE FROM SORouting Where Site = #{site} and OrderNo = #{orderNo} and itemNo = #{itemNo} Update SORouting Set PreItemNo = Isnull((Select Max(D.ItemNo) as PreItemNo from SORouting as D Where D.Site = SORouting.Site and D.OrderNo = SORouting.OrderNo and SORouting.ItemNo > D.ItemNo), 0) , NextItemNo = Isnull((Select Min(D.ItemNo) as NextItemNo from SORouting as D Where D.Site = SORouting.Site and D.OrderNo = SORouting.OrderNo and D.ItemNo > SORouting.ItemNo), 0) where Site = #{site} and OrderNo = #{orderNo} update calendar_exception set excepttime1 = #{excepttime1} , exceptduration1 = #{exceptduration1} , excepttime2 = #{excepttime2} , exceptduration2 = #{exceptduration2} , excepttime3 = #{excepttime3} , exceptduration3 = #{exceptduration3} , excepttime4 =#{excepttime4} , exceptduration4 =#{exceptduration4} , excepttime5 = #{excepttime5} , exceptduration5 =#{exceptduration5} , excepttime6 = #{excepttime6} , exceptduration6 = #{exceptduration6} , worktime =#{worktime} , datetype = #{datetype} , exceptexacttime1 =#{exceptexacttime1} , exceptexacttime2 = #{exceptexacttime2} , exceptexacttime3 = #{exceptexacttime3} , exceptexacttime4 = #{exceptexacttime4} , exceptexacttime5 = #{exceptexacttime5} , exceptexacttime6 = #{exceptexacttime6} where site = #{site} AND CalendarID = #{calendarId} AND scheduledate = #{scheduledate} INSERT INTO ReportFileList(ReportID, ReportFamily, Reportfile, ReportType, Remark) VALUES (#{labelNo}, #{labelType}, #{labelName}, #{labelClass}, #{remark}) UPDATE ReportFileList SET ReportFamily = #{labelType}, Reportfile = #{labelName}, ReportType = #{labelClass}, Remark = #{remark} AND ReportID = #{labelNo} DELETE FROM ReportFileList AND ReportID = #{labelNo} INSERT INTO ReportFileDefDefault(FamilyID, ReportFamily, ReportID, Remark, SubReportFlag, ParentReportID) VALUES ('*', #{labelType}, #{labelNo}, #{remark}, #{subLabelFlag}, #{parentLabelNo}) UPDATE ReportFileDefDefault SET SubReportFlag = #{subLabelFlag}, ParentReportID = #{parentLabelNo}, Remark = #{remark} AND ReportID = #{labelNo} AND ReportFamily = #{labelType} AND FamilyID = '*' DELETE FROM ReportFileDefDefault AND ReportID = #{labelNo} AND ReportFamily = #{labelType} AND FamilyID = '*' INSERT INTO ReportFileDefCustomer(Site, CustomerID, FamilyID, ReportFamily, ReportID, Remark, SubReportFlag, ParentReportID) VALUES (#{site}, #{customerId}, '*', #{labelType}, #{labelNo}, #{remark}, #{subLabelFlag}, #{parentLabelNo}) UPDATE ReportFileDefCustomer SET SubReportFlag = #{subLabelFlag}, ParentReportID = #{parentLabelNo}, Remark = #{remark} AND ReportID = #{labelNo} AND CustomerID = #{customerId} AND FamilyID = '*' DELETE FROM ReportFileDefCustomer AND ReportID = #{labelNo} AND CustomerID = #{customerId} AND FamilyID = '*' INSERT INTO ReportFileList_UserPrinter(ReportID, UserID, PrinterName, IPAddress, NewPrinterName) VALUES (#{labelNo}, #{userId}, '', #{ipAddress}, #{printerName}) UPDATE ReportFileList_UserPrinter SET IPAddress = #{ipAddress}, NewPrinterName = #{printerName} AND ReportID = #{labelNo} AND UserID = #{userId} DELETE FROM ReportFileList_UserPrinter AND ReportID = #{labelNo} AND UserID = #{userId} INSERT INTO ReportParameters(ReportID, ItemNo, ShowSeqNo, ParameterDesc, ParameterName, ValueType_DB, ValueType, OptionValue, DefaultValue) VALUES (#{labelNo}, #{itemNo}, #{showSeqNo}, #{parameterDesc}, #{parameterName}, #{valueTypeDb}, #{valueType}, #{optionValue}, #{defaultValue}) UPDATE ReportParameters SET OptionValue = #{optionValue}, DefaultValue = #{defaultValue}, ShowSeqNo = #{showSeqNo} AND ReportID = #{labelNo} AND ItemNo = #{itemNo} DELETE FROM ReportParameters AND ReportID = #{labelNo} AND ItemNo = #{itemNo} INSERT INTO ReportContentItem(ReportID, ItemNo, ShowSeqNo, ItemDesc, ObjectName, ObjectGroup, DBFieldName, SequenceNoflag, SequenceBits, [Interval]) VALUES (#{labelNo}, #{itemNo}, #{showSeqNo}, #{itemDesc}, #{objectName}, #{objectGroup}, #{dbFieldName}, #{sequenceNoFlag}, #{sequenceBits}, #{intervalValue}) UPDATE ReportContentItem SET ShowSeqNo = #{showSeqNo}, ObjectName = #{objectName}, ObjectGroup = #{objectGroup}, DBFieldName = #{dbFieldName}, SequenceNoflag = #{sequenceNoFlag}, SequenceBits = #{sequenceBits}, [Interval] = #{intervalValue}, ItemDesc = #{itemDesc} AND ReportID = #{labelNo} AND ItemNo = #{itemNo} DELETE FROM ReportContentItem AND ReportID = #{labelNo} AND ItemNo = #{itemNo} DELETE FROM ReportContentItem AND ReportID = #{labelNo} INSERT INTO ReportContentItem(ReportID, ItemNo, ShowSeqNo, ItemDesc, ObjectName, ObjectGroup, DBFieldName, SequenceNoflag, SequenceBits, [Interval]) SELECT #{labelNo}, ItemNo, ShowSeqNo, ItemDesc, ObjectName, ObjectGroup, DBFieldName, SequenceNoflag, SequenceBits, [Interval] FROM ReportContentItem WHERE ReportID = #{newLabelNo} DELETE FROM ReportContentItem_SeqRule AND ReportID = #{labelNo} AND ItemNo = #{itemNo} AND SeqNo = #{seqNo} INSERT INTO ReportFile_SeqInfo(ReportID, ItemNo, KeyInfo, LastSeqNo) VALUES (#{labelNo}, #{itemNo}, #{keyInfo}, #{lastSeqNo}) UPDATE ReportFile_SeqInfo SET KeyInfo = #{keyInfo}, LastSeqNo = #{lastSeqNo} AND ReportID = #{labelNo} AND ItemNo = #{itemNo} AND KeyInfo = #{oriKeyInfo} DELETE FROM ReportFile_SeqInfo AND ReportID = #{labelNo} AND ItemNo = #{itemNo} AND KeyInfo = #{keyInfo} INSERT INTO Calendar_Exception_Shift(Site, CalendarID, ShiftNo, ScheduleDate, ShiftDesc, StartExactTime, EndExactTime, StartTime, EndTime) SELECT site, #{calendarId}, ShiftNo, #{scheduledate}, ShiftDesc, StartExactTime, EndExactTime, StartTime, EndTime FROM Calendar_DateType_Shift WHERE DateType = #{datetype} AND site = #{site} DELETE Calendar_Exception_Shift WHERE site = #{site} AND CalendarID = #{calendarId} AND scheduledate = #{scheduledate}