diff --git a/.vs/ICSSoft.FromERP/v16/.suo b/.vs/ICSSoft.FromERP/v16/.suo index d850f42..bdb9766 100644 Binary files a/.vs/ICSSoft.FromERP/v16/.suo and b/.vs/ICSSoft.FromERP/v16/.suo differ diff --git a/ICSSoft.FromERP/SyncMoHour_Rhyton.cs b/ICSSoft.FromERP/SyncMoHour_Rhyton.cs index 38e16cc..8cfc043 100644 --- a/ICSSoft.FromERP/SyncMoHour_Rhyton.cs +++ b/ICSSoft.FromERP/SyncMoHour_Rhyton.cs @@ -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' + + diff --git a/ICSSoft.Test/Program.cs b/ICSSoft.Test/Program.cs index 09b8fbd..20172ab 100644 --- a/ICSSoft.Test/Program.cs +++ b/ICSSoft.Test/Program.cs @@ -13,7 +13,7 @@ namespace ICSSoft.Test //ICSVendor test = new ICSVendor(); //test.Execute(); - IcsMo_Rhtyon test = new IcsMo_Rhtyon(); + SyncMoHour_Rhyton test = new SyncMoHour_Rhyton(); test.Execute(); // var ss= ICSHelper.ApiSign("sj_w_id", "70FF7F01C5899A5ACAAD4ECB7FA5B3C5", 1724650261);