|
|
@ -61,9 +61,22 @@ namespace ICSSoft.FromERP |
|
|
|
} |
|
|
|
|
|
|
|
string sql = @"
|
|
|
|
|
|
|
|
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempSyncMoHour_Rhyton') and type='U') |
|
|
|
DROP TABLE #tempSyncMoHour_Rhyton |
|
|
|
|
|
|
|
|
|
|
|
select |
|
|
|
a.* |
|
|
|
,(a.PTime+cast( a.ManualTime as decimal(18,6) )) as MachiningTotalTime |
|
|
|
,case when (a.EqpCalcType='1'and a.ResQty>0) then (a.PTime+cast( a.ManualTime as decimal(18,6) ))/a.ResQty |
|
|
|
else 0 end as EqpTotalTime |
|
|
|
,(a.PTime+cast( a.ManualTime as decimal(18,6) )-a.TotalTime) as HourDiff |
|
|
|
into #tempSyncMoHour_Rhyton |
|
|
|
from |
|
|
|
( |
|
|
|
|
|
|
|
|
|
|
|
select |
|
|
|
a.MoCode |
|
|
|
,a.ItemCode |
|
|
@ -75,13 +88,14 @@ a.MoCode |
|
|
|
,((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 |
|
|
|
|
|
|
|
,a.Status |
|
|
|
,a.TenantId |
|
|
|
,a.CreationTime MTIME |
|
|
|
,a.CreatorUserId |
|
|
|
,a.CreatorUserName |
|
|
|
,a.EqpCalcType |
|
|
|
|
|
|
|
into #tempSyncMoHour_Rhyton |
|
|
|
from |
|
|
|
( |
|
|
|
select |
|
|
@ -103,6 +117,7 @@ from |
|
|
|
,GETDATE() CreationTime |
|
|
|
,'job' as CreatorUserId |
|
|
|
,'job' CreatorUserName |
|
|
|
,h1.EqpCalcType |
|
|
|
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 |
|
|
@ -131,10 +146,11 @@ and a.MoStatus='mostatus_close' |
|
|
|
and a.Default6='0' |
|
|
|
and a.TenantId='{0}' |
|
|
|
and e.OpControl='10000000' |
|
|
|
and (h2.id is null) |
|
|
|
and h2.Status='No' |
|
|
|
) a |
|
|
|
where 1=1 |
|
|
|
order by a.MoCode, a.OpSeq asc |
|
|
|
) a |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -169,17 +185,36 @@ a.MoCode |
|
|
|
,a.TotalTime |
|
|
|
,a.PTime |
|
|
|
,a.ManualTime |
|
|
|
,(a.PTime+cast( a.ManualTime as decimal(18,6) )) |
|
|
|
,case when a.ResQty>0 then (a.PTime+cast( a.ManualTime as decimal(18,6) ))/a.ResQty |
|
|
|
else 0 end as EqpTotalTime |
|
|
|
,a.MachiningTotalTime |
|
|
|
,a.EqpTotalTime |
|
|
|
,a.ResQty |
|
|
|
,(a.PTime+cast( a.ManualTime as decimal(18,6) )-a.TotalTime) |
|
|
|
,a.HourDiff |
|
|
|
,a.Status |
|
|
|
,a.TenantId |
|
|
|
,a.MTIME |
|
|
|
,a.CreatorUserId |
|
|
|
,a.CreatorUserName |
|
|
|
from #tempSyncMoHour_Rhyton a |
|
|
|
left join IcsMoHourData b on a.MoCode=b.MoCode and a.OpCode=b.OpCode |
|
|
|
where b.Id is null |
|
|
|
|
|
|
|
|
|
|
|
update IcsMoHourData |
|
|
|
set STime=a.STime |
|
|
|
,Rtime=a.Rtime |
|
|
|
,TotalTime=a.TotalTime |
|
|
|
,RealTime=a.PTime |
|
|
|
,ManualTime=a.ManualTime |
|
|
|
,MachiningTotalTime=a.MachiningTotalTime |
|
|
|
,EqpTotalTime=a.EqpTotalTime |
|
|
|
,ResQty=a.ResQty |
|
|
|
,HourDiff=a.HourDiff |
|
|
|
from #tempSyncMoHour_Rhyton a |
|
|
|
join IcsMoHourData b on a.MoCode=b.MoCode and a.OpCode=b.OpCode |
|
|
|
where 1=1 |
|
|
|
and b.Status='No' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|