diff --git a/.vs/ICSSoft.FromERP/v16/.suo b/.vs/ICSSoft.FromERP/v16/.suo index 3ac6097..fb8f56a 100644 Binary files a/.vs/ICSSoft.FromERP/v16/.suo and b/.vs/ICSSoft.FromERP/v16/.suo differ diff --git a/ICSSoft.FromERP/ICSSoft.FromERP.csproj b/ICSSoft.FromERP/ICSSoft.FromERP.csproj index ba6965c..a6e3731 100644 --- a/ICSSoft.FromERP/ICSSoft.FromERP.csproj +++ b/ICSSoft.FromERP/ICSSoft.FromERP.csproj @@ -93,6 +93,7 @@ + diff --git a/ICSSoft.FromERP/IcsAutoSyncMoRoute_Rhtyon.cs b/ICSSoft.FromERP/IcsAutoSyncMoRoute_Rhtyon.cs new file mode 100644 index 0000000..55c7010 --- /dev/null +++ b/ICSSoft.FromERP/IcsAutoSyncMoRoute_Rhtyon.cs @@ -0,0 +1,104 @@ +using Quartz; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + + +namespace ICSSoft.FromERP +{ + + /// + /// 工单工艺自动生成(锐腾) + /// + public class IcsAutoSyncMoRoute_Rhtyon : 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 conERPStr = ICSHelper.GetERPConnectString(); + string conStr = ICSHelper.GetConnectString(); + string Namespace = this.GetType().Namespace; + string Class = this.GetType().Name; + + // List itemCodeList = new List() { "A2001", "A2002", "KA10", "A2003" }; + DataTable dt = ICSHelper.GetERPDB(conStr); + + //循环组织 + foreach (DataRow dr in dt.Rows) + { + string erpName = ICSHelper.GetConfigString()["ERPDB"]; + string TenantId = dr["TenantId"].ToString(); + string TenantCode = dr["TenantCode"].ToString(); + + + string sql1 = @" +select a.MoCode,a.MoSeq, a.Id,a.ItemCode ,b.RouteCode +from IcsMo a with(nolock) +left join IcsItem2Route b with(nolock) on a.ItemCode=b.ItemCode and b.IsRef='Y' and a.TenantId=b.TenantId + where a.MoStatus='mostatus_initial' +and not exists (select MoCode from IcsMo2Route with(nolock) where MoCode=a.MoCode) and a.TenantId='" + TenantId + "' " + + " and b.RouteCode is not null "; + + var itemDt = ICSHelper.ExecuteTable(conStr, sql1); + if (itemDt != null && itemDt.Rows.Count > 0) + { + //循环工单 + string sql2 = ""; + for (int i = 0; i < itemDt.Rows.Count; i++) + { + var item = itemDt.Rows[i]; + + //工艺路线表头 + sql2 += @" + insert into IcsMo2Route (MoId,RouteId,MoCode,MoSeq, RouteCode,IsMRoute, TenantId,CreationTime,CreatorUserId,CreatorUserName) + select top 1 " + item["Id"].ToInt64() + ",Id,'" + item["MoCode"].ToString() + "'," + item["MoSeq"].ToInt64() + ",RouteCode,'Y','" + TenantId + "',GETDATE(),'c65321b94c804dc26eb93a0ba67c8a2a','xusc' from IcsItem2Route a " + + " where ItemCode='" + item["ItemCode"].ToString() + "' " + + "and a.IsRef='Y' and TenantId='" + TenantId + "' "; + + + //工艺路线明细 + sql2 += @" + insert into IcsMoRoute2Op (MoId,RouteId,OpId,MoCode,MoSeq, RouteCode,OpCode,OpSeq,OpControl ,OpLevel ,OpControlSeq,ParallelOp + ,TenantId,CreationTime,CreatorUserId,CreatorUserName) + select " + item["Id"].ToInt64() + ",RouteId,OpId,'" + item["MoCode"].ToString() + "'," + item["MoSeq"].ToInt64() + ",RouteCode,OpCode,OpSeq,OPControl,'A',OpControlSeq,'N','" + TenantId + "',GETDATE(),'c65321b94c804dc26eb93a0ba67c8a2a','xusc' from IcsItemRoute2Op a " + + "where ItemCode='" + item["ItemCode"].ToString() + + "' and a.RouteCode='"+ item["RouteCode"].ToString() + "' and TenantId='" + TenantId + "' "; + + sql2 += @" update icsmo set MoRoute='" + item["RouteCode"].ToString() + "' where Id=" + item["Id"].ToInt64() + " and TenantId='" + TenantId + "' "; + } + + ICSHelper.ExecuteDate(conStr, sql2); + } + } + + + } + catch (Exception ex) + { + log.Error(ex.ToString()); + } + } + } +} diff --git a/ICSSoft.Test/ICSSoft.Test.csproj b/ICSSoft.Test/ICSSoft.Test.csproj index 90f471d..c41f835 100644 --- a/ICSSoft.Test/ICSSoft.Test.csproj +++ b/ICSSoft.Test/ICSSoft.Test.csproj @@ -94,7 +94,7 @@ - {71BE770C-F5BE-46C8-A81C-1897E28DB761} + {71be770c-f5be-46c8-a81c-1897e28db761} ICSSoft.FromERP