<iftest="repairSOFlag != null and repairSOFlag != ''">
and b.RepairSOFlag like #{repairSOFlag}
</if>
<iftest="scrapFlag != null and scrapFlag != ''">
and case when a.ReportQty!=0 then Round((a.ReportQty-a.ApproveQty)*100/a.ReportQty,2) else 0 end >a.c_sys_scrap_rate
</if>
</where>
order by a.ReportDate desc
</select>
@ -1321,21 +1324,37 @@
where ReportedManfTime>12 and a.AssJobSeqNo is not null
union all
select site 工厂编码,SeqNo 派工单号,开工时间,null as 报工时间,null as 上道报工时间,null as 开工间隔
,null as 生产时间,领料重量,[48小时报工重量],null as 完成率,'报工重量不足' as 备注
from
(
select a1.site,a1.SeqNo,a1.PreviousSeqNo,a1.开工时间,a1.S_ScheduledDate,isnull(a3.QtyApprove*dbo.Get_Part_NetWeight(a3.Site,a3.partNo)/1000.0,0) 领料重量,sum(ApproveQty*dbo.Get_Part_NetWeight(a1.Site,a1.partNo)/1000.0) as [48小时报工重量]
from
(select a.site,a.partNo, a.SeqNo,a.PreviousSeqNo,min(b.EventTime) as 开工时间,a.S_ScheduledDate
from SOScheduledRouting a left join SFDC_TimeHist b on a.SeqNo=b.SeqNo and a.site=b.site and b.EventDesc='开始生产'
where a.PreviousSeqNo is not null and b.EventTime is not null and a.scheduleType='生产订单派工单'
group by a.site,a.SeqNo,a.PreviousSeqNo,a.S_ScheduledDate,a.partNo) a1
left join SOScheduledRouting a3 on a1.PreviousSeqNo=a3.SeqNo and a1.Site=a3.Site
left join sfdc a2 on a1.Site=a2.Site and a1.SeqNo=a2.AssJobSeqNo
where a2.StatisticDate is not null and 48>=DATEDIFF(HOUR, 开工时间, a2.StatisticDate)
group by a1.site,a1.SeqNo,a1.PreviousSeqNo,a1.开工时间,a1.S_ScheduledDate,a3.QtyApprove,a3.Site,a3.partNo) as a11
where 领料重量>[48小时报工重量]
select 工厂编码,派工单号,开工时间,报工时间,上道报工时间,DATEDIFF(HOUR, 开工时间, 报工时间) as 开工间隔,生产时间,领料重量,[48小时报工重量],完成率,备注
from (
select a.site 工厂编码,a.SeqNo 派工单号,min(EventTime) as 开工时间,a.LastReportDate 报工时间,null as 上道报工时间,null as 开工间隔,
null 生产时间,null as 领料重量,null as [48小时报工重量],null as 完成率, '完工不及时' as 备注
from SOScheduledRouting a left join SFDC_TimeHist b on a.Site=b.Site and a.SeqNo=b.SeqNo and EventDesc='开始生产'
where a.ClosedFlag='Y'
GROUP BY a.site,a.SeqNo,a.LastReportDate
) aaaaaa
where DATEDIFF(HOUR, 开工时间, 报工时间) >48
<!-- select site 工厂编码,SeqNo 派工单号,开工时间,null as 报工时间,null as 上道报工时间,null as 开工间隔-->
<!-- ,null as 生产时间,领料重量,[48小时报工重量],null as 完成率,'报工重量不足' as 备注-->
<!-- from-->
<!-- (-->
<!-- select a1.site,a1.SeqNo,a1.PreviousSeqNo,a1.开工时间,a1.S_ScheduledDate,isnull(a3.QtyApprove*dbo.Get_Part_NetWeight(a3.Site,a3.partNo)/1000.0,0) 领料重量,sum(ApproveQty*dbo.Get_Part_NetWeight(a1.Site,a1.partNo)/1000.0) as [48小时报工重量]-->
<!-- from-->
<!-- (select a.site,a.partNo, a.SeqNo,a.PreviousSeqNo,min(b.EventTime) as 开工时间,a.S_ScheduledDate-->
<!-- from SOScheduledRouting a left join SFDC_TimeHist b on a.SeqNo=b.SeqNo and a.site=b.site and b.EventDesc='开始生产'-->
<!-- where a.PreviousSeqNo is not null and b.EventTime is not null and a.scheduleType='生产订单派工单'-->
<!-- group by a.site,a.SeqNo,a.PreviousSeqNo,a.S_ScheduledDate,a.partNo) a1-->
<!-- left join SOScheduledRouting a3 on a1.PreviousSeqNo=a3.SeqNo and a1.Site=a3.Site-->
<!-- left join sfdc a2 on a1.Site=a2.Site and a1.SeqNo=a2.AssJobSeqNo-->
<!-- where a2.StatisticDate is not null and 48>=DATEDIFF(HOUR, 开工时间, a2.StatisticDate)-->
<!-- group by a1.site,a1.SeqNo,a1.PreviousSeqNo,a1.开工时间,a1.S_ScheduledDate,a3.QtyApprove,a3.Site,a3.partNo) as a11-->
<!-- where 领料重量>[48小时报工重量]-->
union all
select site 工厂编码,SeqNo 派工单号, null as 开工时间,null as 报工时间,null as上道报工时间,null as 开工间隔,
@ -1370,7 +1389,9 @@
<iftest="query.partDesc != null and query.partDesc != '' ">
and dbo.Get_Part_SpecDesc(r2.site,r2.partNo) like #{query.partDesc}
</if>
<iftest="query.remark != null and query.remark != '' ">