diff --git a/.vs/ICSSoft.FromERP/v16/.suo b/.vs/ICSSoft.FromERP/v16/.suo index ea1bc33..56c61f4 100644 Binary files a/.vs/ICSSoft.FromERP/v16/.suo and b/.vs/ICSSoft.FromERP/v16/.suo differ diff --git a/ICSSoft.FromERP/App.config b/ICSSoft.FromERP/App.config index edb105e..7b62e13 100644 --- a/ICSSoft.FromERP/App.config +++ b/ICSSoft.FromERP/App.config @@ -2,7 +2,8 @@ - + + @@ -18,6 +19,7 @@ + diff --git a/ICSSoft.FromERP/ICSSoft.FromERP.csproj b/ICSSoft.FromERP/ICSSoft.FromERP.csproj index f049210..770c2cf 100644 --- a/ICSSoft.FromERP/ICSSoft.FromERP.csproj +++ b/ICSSoft.FromERP/ICSSoft.FromERP.csproj @@ -177,6 +177,7 @@ + diff --git a/ICSSoft.FromERP/IcsMo_Rhtyon.cs b/ICSSoft.FromERP/IcsMo_Rhtyon.cs index 421f108..d79f098 100644 --- a/ICSSoft.FromERP/IcsMo_Rhtyon.cs +++ b/ICSSoft.FromERP/IcsMo_Rhtyon.cs @@ -63,7 +63,9 @@ namespace ICSSoft.FromERP 0 as RCVQuantity, A13.Code as DepCode, A22.Code as WHCode, - 'mostatus_initial' as MOStatus, + case when A.DocState=2 then 'mostatus_initial' + when A.DocState=3 then 'mostatus_close' + else 'mostatus_initial' end as MOStatus, A2.Description as MOMemo, '2' as ERPStatus, A.StartDate as StartDate, @@ -85,6 +87,7 @@ namespace ICSSoft.FromERP ,A12.Code as TenantId ,A12.id as Org ,a.DescFlexField_PrivateDescSeg1 AS EATTRIBUTE1 + ,a.DescFlexField_PrivateDescSeg2 AS EATTRIBUTE2 ,( select b1.code from {1}.dbo.UBF_Sys_ExtEnumType a1 left join {1}.dbo.UBF_Sys_ExtEnumValue b1 on a1.ID=b1.ExtEnumType @@ -170,11 +173,11 @@ else Convert(varchar(10),a.ActualCompleteDate,120 ) end as ActualCompleteDate values.Add("LastModifierUserId", "'" + ConstWorkPoint.Muser + "'"); values.Add("LastModifierUserName", "'" + ConstWorkPoint.Musername + "'"); values.Add("LastModificationTime", "a.Mtime");//操作时间 - //values.Add("Default1", "a.EATTRIBUTE1"); - //values.Add("Default2", "a.NeedType"); + values.Add("Default1", "a.EATTRIBUTE1"); + values.Add("CusItemCode", "a.EATTRIBUTE2"); values.Add("DocType", "a.MoDocType"); - // values.Add("Default3", "a.ActualCompleteDate"); - + // values.Add("Default3", "a.ActualCompleteDate"); + //更新存在数据 sql += ICSHelper.UpdateSQL("b", values) + @" #TempMO a diff --git a/ICSSoft.FromERP/SyncCas_Jinyang.cs b/ICSSoft.FromERP/SyncCas_Jinyang.cs index d6bcd90..554ce03 100644 --- a/ICSSoft.FromERP/SyncCas_Jinyang.cs +++ b/ICSSoft.FromERP/SyncCas_Jinyang.cs @@ -67,6 +67,8 @@ DROP TABLE #tempSyncCas_Jinyang select * ,a.CreateTime as MTime into #tempSyncCas_Jinyang from [ICSDomeAmb] a with( nolock) where a.CreateTime>@LastTime +and free1 <>'15' and Free2 not like '%e%' and free1<>'0' + and LotNO <>'' select a.* diff --git a/ICSSoft.FromERP/SyncMoHour_Rhyton.cs b/ICSSoft.FromERP/SyncMoHour_Rhyton.cs new file mode 100644 index 0000000..3dee8b5 --- /dev/null +++ b/ICSSoft.FromERP/SyncMoHour_Rhyton.cs @@ -0,0 +1,174 @@ +using ICSSoft.FromERP.Model; +using Newtonsoft.Json; +using Quartz; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ICSSoft.FromERP +{ + /// + /// 工单工时统计(锐腾) + /// + public class SyncMoHour_Rhyton : IJob + { + private static object key = new object(); + private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public void Execute(IJobExecutionContext context) + { + try + { + lock (key) + { + log.Info("开始……………………………………………………………………"); + Execute(); + log.Info("结束……………………………………………………………………"); + } + } + catch (Exception ex) + { + log.Error(ex.ToString()); + } + } + + public void Execute() + { + try + { + string conStr = ICSHelper.GetConnectString(); + string Namespace = this.GetType().Namespace; + // string Class = this.GetType().Name; + DataTable dt = ICSHelper.GetERPDB(conStr); + foreach (DataRow dr in dt.Rows) + { + var dtNowBegin = new DateTime(2000, 1, 1, 0, 0, 0);//默认开始时间 + var dtNow = DateTime.Now; + string erpName = ICSHelper.GetConfigString()["ERPDB"]; + string TenantId = dr["TenantId"].ToString();//mes 组织 + string TenantCode = dr["TenantCode"].ToString(); + string ErpId = dr["ErpID"].ToString(); //erpID + string Class = this.GetType().Name + TenantCode; + erpName = string.Format(erpName, TenantId); + + string sql0 = " SELECT top 1 ModifyDate FROM ICSERPTime where ClassName='" + Class + "'"; + var lastDate = ICSHelper.ExecuteScalar(conStr, sql0).ToDateOrNull(); + if (!lastDate.HasValue) + { + lastDate = dtNowBegin; + } + + 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.MoCode +,a.ItemCode +,a.OpCode +,a.MoPlanQty +,a.STime +,cast( cast( isnull( a.ProduceTime,0) as decimal(18,4)) /cast( 3600 as decimal(18,4)) as decimal(18,2)) as PTime +,a.ManualTime +,a.Status +,a.TenantId + ,a.CreationTime MTIME + ,a.CreatorUserId + ,a.CreatorUserName + + into #tempSyncMoHour_Rhyton +from +( + select + a.MoCode + ,a.ItemCode + --,b.ItemName + ,e.OpCode + ,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 + ,g.ProduceTime + ,f.RecordingHours as ManualTime + --,0.00 as AlterTime + ,'No' as Status + ,'{0}' as TenantId + ,GETDATE() CreationTime + ,'job' as CreatorUserId + ,'job' CreatorUserName + 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 IcsOP e2 with(nolock) on e.OpCode=e2.OPCode and e.TenantId=e2.TenantId +left join +( +select sum(RecordingHours) RecordingHours, +t.MoCode,t.OpCode +from IcsManualRecording t with(nolock) +group by t.MoCode,t.OpCode +) f on a.MoCode=f.MoCode and e.OpCode=f.OpCode +left join +(select t.MoCode,t.OpCode,SUM( datediff(SS,t.BeginTime,t.EndTime)) ProduceTime from IcsLotOnWipDetail t with(nolock) +where t.CollectStatus='End' +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 +where 1=1 +and a.TenantId='{0}' +and a.CreationTime>@LastTime +) a +where 1=1 +order by a.MoCode, a.OpSeq asc + + + + insert into IcsMoHourData ( + MoCode + ,ItemCode + ,OpCode + ,Qty + ,STime + ,RealTime + ,ManualTime + ,Status + ,TenantId + ,CreationTime + ,CreatorUserId + ,CreatorUserName + ) +select * from #tempSyncMoHour_Rhyton "; + + sql = string.Format(sql, TenantId); + sql = ICSHelper.Time(Namespace, Class, TenantId, sql, "#tempSyncMoHour_Rhyton"); + // sql += "DROP TABLE #tempSyncCas_Jinyang"; + + + // sql += @""; + + + ICSHelper.ExecuteDate(conStr, sql); + + } + } + catch (Exception ex) + { + log.Error(ex.ToString()); + } + } + } +} diff --git a/ICSSoft.Test/Program.cs b/ICSSoft.Test/Program.cs index 1913a4a..09b8fbd 100644 --- a/ICSSoft.Test/Program.cs +++ b/ICSSoft.Test/Program.cs @@ -13,7 +13,7 @@ namespace ICSSoft.Test //ICSVendor test = new ICSVendor(); //test.Execute(); - IcsMainCategoryCode_Rhtyon test = new IcsMainCategoryCode_Rhtyon(); + IcsMo_Rhtyon test = new IcsMo_Rhtyon(); test.Execute(); // var ss= ICSHelper.ApiSign("sj_w_id", "70FF7F01C5899A5ACAAD4ECB7FA5B3C5", 1724650261);