Select s.NeedDate,s.PartNo,p.PartDescription+' / '+p.Spec as PartDescription,R.WorkcenterNo,W.WorkCenterDesc,T.Site,T.OrderNo,T.ItemNo,T.SeqNo,T.ReportDate,T.OperatorID,O.OperatorName,
(Case when T.Direction='+' then 1 else -1 end)*T.ReportQty as ReportQty,(Case when T.Direction='+' then 1 else -1 end)*T.ApproveQty as ApproveQty
,(Case when T.Direction='+' then 1 else -1 end)*T.ReportedSetupTime as ReportedSetupTime,(Case when T.Direction='+' then 1 else -1 end)*T.ReportedManfTime as ReportedManfTime,
(Case when T.Direction='+' then 1 else -1 end)*T.ReportedCleanupTime as ReportedCleanupTime,T.ScrapReason,T.DownTimeReason,T.Reverseflag,T.RelevantSeqNo,T.Remark,T.starttime,
T.finishtime,T.downtime,(T.ReportQty - T.ApproveQty) as DefectQty,T.AssJobSeqNo,SS.QtyRequired,SS.S_ResourceID,R.OperationDesc,P.ConfigurationTemplateID as CustomerName,
P.Remark as CustPartNo,Round((case when T.ReportedManfTime=0 then 999999 else T.ApproveQty / T.ReportedManfTime end),2) as ActRunRate,T.Scheduled_ShiftNo,T.Scheduled_Date,
left join SOScheduledRouting as SS on T.Site=SS.Site and T.OrderNo=SS.OrderNo and T.ItemNo=SS.ItemNo and T.AssJobSeqNo=SS.SeqNo,ShopOrder as S,SORouting as R,Part as P,WorkCenter as W,Operator as O
<!-- Select s.NeedDate,s.PartNo,p.PartDescription+' / '+p.Spec as PartDescription,R.WorkcenterNo,W.WorkCenterDesc,T.Site,T.OrderNo,T.ItemNo,T.SeqNo,T.ReportDate,T.OperatorID,O.OperatorName,-->
<!-- (Case when T.Direction='+' then 1 else -1 end)*T.ReportQty as ReportQty,(Case when T.Direction='+' then 1 else -1 end)*T.ApproveQty as ApproveQty-->
<!-- ,(Case when T.Direction='+' then 1 else -1 end)*T.ReportedSetupTime as ReportedSetupTime,(Case when T.Direction='+' then 1 else -1 end)*T.ReportedManfTime as ReportedManfTime,-->
<!-- (Case when T.Direction='+' then 1 else -1 end)*T.ReportedCleanupTime as ReportedCleanupTime,T.ScrapReason,T.DownTimeReason,T.Reverseflag,T.RelevantSeqNo,T.Remark,T.starttime,-->
<!-- T.finishtime,T.downtime,(T.ReportQty - T.ApproveQty) as DefectQty,T.AssJobSeqNo,SS.QtyRequired,SS.S_ResourceID,R.OperationDesc,P.ConfigurationTemplateID as CustomerName,-->
<!-- P.Remark as CustPartNo,Round((case when T.ReportedManfTime=0 then 999999 else T.ApproveQty / T.ReportedManfTime end),2) as ActRunRate,T.Scheduled_ShiftNo,T.Scheduled_Date,-->
<!-- left join SOScheduledRouting as SS on T.Site=SS.Site and T.OrderNo=SS.OrderNo and T.ItemNo=SS.ItemNo and T.AssJobSeqNo=SS.SeqNo,ShopOrder as S,SORouting as R,Part as P,WorkCenter as W,Operator as O-->
<!-- <where>-->
<!-- and T.Site=S.Site and T.OrderNo=S.OrderNo and T.Site=R.Site and T.OrderNo=R.OrderNo and T.ItemNo=R.ItemNo and s.Site=p.Site-->
<!-- and s.PartNo=p.PartNo and R.Site=W.Site and R.WorkCenterNo=W.WorkCenterNo and T.Site=O.Site and T.OperatorID=O.OperatorID-->
<!-- and T.Site in (Select Site from AccessSite where upper(UserID)=#{user})-->
<!-- <if test=" site != null and site != ''">-->
<!-- AND T.Site = #{site}-->
<!-- </if>-->
<!-- <if test=" partNo != null and partNo != ''">-->
<!-- AND s.PartNo like #{partNo}-->
<!-- </if>-->
<!-- <if test=" partDescription != null and partDescription != ''">-->
<!-- AND p.PartDescription+' / '+p.Spec like #{partDescription}-->
<!-- </if>-->
<!-- <if test=" orderNo != null and orderNo != ''">-->
<!-- AND T.OrderNo = #{orderNo}-->
<!-- </if>-->
<!-- <if test=" operatorID != null and operatorID != ''">-->
<!-- AND T.OperatorID like #{operatorID}-->
<!-- </if>-->
<!-- <if test=" workCenterNo != null and workCenterNo != ''">-->
<!-- AND R.WorkcenterNo like #{workCenterNo}-->
<!-- </if>-->
<!-- <if test=" sResourceID != null and sResourceID != ''">-->
Select T.Site,T.OrderNo,T.ItemNo,T.SeqNo,T.ReportDate,T.OperatorID,T.Direction,T.ReportQty,T.ApproveQty,Round(T.ReportedSetupTime,2) as reportedSetupTime,R.WorkcenterNo,W.WorkCenterDesc,O.OperatorName
,Round(T.ReportedManfTime,2) as reportedManfTime,T.ReportedCleanupTime,T.ScrapReason,T.DownTimeReason,T.Reverseflag,T.RelevantSeqNo,T.Remark
,T.starttime,T.finishtime,T.downtime,T.AssJobSeqNo,(T.ReportQty - T.ApproveQty) as DefectQty