|
|
@ -64,10 +64,6 @@ namespace ICSSoft.FromERP |
|
|
|
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempSyncMoHour_Rhyton') and type='U') |
|
|
|
DROP TABLE #tempSyncMoHour_Rhyton |
|
|
|
|
|
|
|
--工单工时同步表 |
|
|
|
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempSyncMoHourYesData_Rhyton') and type='U') |
|
|
|
DROP TABLE #tempSyncMoHourYesData_Rhyton |
|
|
|
|
|
|
|
select |
|
|
|
a.MoCode |
|
|
|
,a.ItemCode |
|
|
@ -75,6 +71,7 @@ a.MoCode |
|
|
|
,a.MoPlanQty |
|
|
|
,a.STime |
|
|
|
,a.Rtime |
|
|
|
,a.ResQty |
|
|
|
,((a.STime*a.MoPlanQty)+a.Rtime) as TotalTime |
|
|
|
,cast( cast( isnull( a.ProduceTime,0) as decimal(18,6)) /cast( 3600 as decimal(18,6)) as decimal(18,6)) as PTime |
|
|
|
,a.ManualTime |
|
|
@ -95,30 +92,11 @@ from |
|
|
|
,e.OpSeq |
|
|
|
--,e2.OPName |
|
|
|
,a.MoPlanQty |
|
|
|
, |
|
|
|
( |
|
|
|
select sum(isnull( f.Stime,0)) Stime |
|
|
|
from IcsItem2Route h with(nolock) |
|
|
|
join IcsItemRoute2Op f with(nolock) on h.ItemCode=f.ItemCode and h.RouteCode=f.RouteCode |
|
|
|
where h.IsRef='Y' |
|
|
|
and h.ItemCode=a.ItemCode |
|
|
|
and f.OpCode=e.OpCode |
|
|
|
group by h.ItemCode,f.OpCode |
|
|
|
) |
|
|
|
as STime |
|
|
|
, |
|
|
|
( |
|
|
|
select sum(isnull( f.Rtime,0)) Rtime |
|
|
|
from IcsItem2Route h with(nolock) |
|
|
|
join IcsItemRoute2Op f with(nolock) on h.ItemCode=f.ItemCode and h.RouteCode=f.RouteCode |
|
|
|
where h.IsRef='Y' |
|
|
|
and h.ItemCode=a.ItemCode |
|
|
|
and f.OpCode=e.OpCode |
|
|
|
group by h.ItemCode,f.OpCode |
|
|
|
) |
|
|
|
as Rtime |
|
|
|
,g.ProduceTime |
|
|
|
,f.RecordingHours as ManualTime |
|
|
|
,isnull( h1.Stime,0) STime |
|
|
|
,isnull( h1.Rtime,0) RTime |
|
|
|
,isnull(h1.ResQty,0) ResQty |
|
|
|
,isnull( g.ProduceTime,0) ProduceTime |
|
|
|
,isnull(f.RecordingHours,0) as ManualTime |
|
|
|
--,0.00 as AlterTime |
|
|
|
,'No' as Status |
|
|
|
,'{0}' as TenantId |
|
|
@ -128,7 +106,7 @@ from |
|
|
|
from IcsMo a with(nolock) |
|
|
|
join IcsInventory b with(nolock) on a.ItemCode=b.ItemCode and a.TenantId=b.TenantId |
|
|
|
join IcsMo2Route d with(nolock) on a.MoCode=d.MoCode and d.IsMRoute='Y' and a.TenantId=d.TenantId |
|
|
|
join IcsMoRoute2Op e with(nolock) on d.MoCode=e.MoCode and d.RouteId=e.RouteId and d.TenantId=e.TenantId |
|
|
|
join IcsMoRoute2Op e with(nolock) on d.MoCode=e.MoCode and d.RouteCode=e.RouteCode and d.TenantId=e.TenantId |
|
|
|
join IcsOP e2 with(nolock) on e.OpCode=e2.OPCode and e.TenantId=e2.TenantId |
|
|
|
left join |
|
|
|
( |
|
|
@ -144,21 +122,20 @@ and t.IsHistory='N' |
|
|
|
and t.CollectForm='Standard' |
|
|
|
group by t.MoCode,t.OpCode |
|
|
|
) g on a.MoCode=g.MoCode and e.OpCode=g.OpCode |
|
|
|
|
|
|
|
left join IcsItem2Route h with(nolock) on b.ItemCode=h.ItemCode and d.RouteCode=h.RouteCode and b.TenantId=h.TenantId |
|
|
|
left join IcsItemRoute2Op h1 with(nolock) on h.ItemCode=h1.ItemCode and h.RouteCode=h1.RouteCode and e.OpCode=h1.OpCode and h.TenantId=h1.TenantId |
|
|
|
left join IcsMoHourData h2 with(nolock) on a.mocode=h2.mocode and e.OpCode=h2.OpCode |
|
|
|
where 1=1 |
|
|
|
and a.TenantId='{0}' |
|
|
|
--and a.CreationTime>@LastTime |
|
|
|
and e.OpControl='10000000' |
|
|
|
and (h2.id is null) |
|
|
|
) a |
|
|
|
where 1=1 |
|
|
|
order by a.MoCode, a.OpSeq asc |
|
|
|
|
|
|
|
|
|
|
|
delete from IcsMoHourData |
|
|
|
where Status='No' |
|
|
|
|
|
|
|
select * into #tempSyncMoHourYesData_Rhyton from IcsMoHourData |
|
|
|
where Status='Yes' |
|
|
|
|
|
|
|
truncate table IcsMoHourData |
|
|
|
|
|
|
|
insert into IcsMoHourData ( |
|
|
|
MoCode |
|
|
@ -171,6 +148,7 @@ truncate table IcsMoHourData |
|
|
|
,RealTime |
|
|
|
,ManualTime |
|
|
|
,MachiningTotalTime |
|
|
|
,ResQty |
|
|
|
,Status |
|
|
|
,TenantId |
|
|
|
,CreationTime |
|
|
@ -188,50 +166,14 @@ a.MoCode |
|
|
|
,a.PTime |
|
|
|
,a.ManualTime |
|
|
|
,(a.PTime+a.ManualTime) |
|
|
|
,a.ResQty |
|
|
|
,a.Status |
|
|
|
,a.TenantId |
|
|
|
,a.MTIME |
|
|
|
,a.CreatorUserId |
|
|
|
,a.CreatorUserName |
|
|
|
from #tempSyncMoHour_Rhyton a |
|
|
|
left join IcsMoHourData b with(nolock) on a.MoCode=b.MoCode and a.OpCode=b.OpCode |
|
|
|
where b.MoCode is null and b.OpCode is null |
|
|
|
|
|
|
|
|
|
|
|
insert into IcsMoHourData ( |
|
|
|
MoCode |
|
|
|
,ItemCode |
|
|
|
,OpCode |
|
|
|
,Qty |
|
|
|
,STime |
|
|
|
,RTime |
|
|
|
,TotalTime |
|
|
|
,RealTime |
|
|
|
,ManualTime |
|
|
|
,AlterTime |
|
|
|
,MachiningTotalTime |
|
|
|
,EqpTotalTime |
|
|
|
,Status |
|
|
|
,TenantId |
|
|
|
,CreationTime |
|
|
|
,CreatorUserId |
|
|
|
,CreatorUserName |
|
|
|
,VerifyUser |
|
|
|
,VerifyDate |
|
|
|
,LastModificationTime |
|
|
|
,LastModifierUserId |
|
|
|
,LastModifierUserName |
|
|
|
) |
|
|
|
|
|
|
|
select a.MoCode,a.ItemCode,a.OpCode,a.Qty,a.STime,a.RTime,a.TotalTime |
|
|
|
,a.RealTime,a.ManualTime |
|
|
|
,a.AlterTime |
|
|
|
,a.MachiningTotalTime |
|
|
|
,a.EqpTotalTime |
|
|
|
,a.Status,a.TenantId |
|
|
|
,a.CreationTime,a.CreatorUserId,a.CreatorUserName,a.VerifyUser,a.VerifyDate |
|
|
|
,a.LastModificationTime,a.LastModifierUserId,a.LastModifierUserName |
|
|
|
from #tempSyncMoHourYesData_Rhyton a |
|
|
|
|
|
|
|
|
|
|
|
";
|
|
|
|