Browse Source

...

Branch_PaiNaWeiSJob
xusc 3 months ago
parent
commit
abb6b8fdad
  1. BIN
      .vs/ICSSoft.FromERP/v16/.suo
  2. 1
      ICSSoft.FromERP/ICSSoft.FromERP.csproj
  3. 104
      ICSSoft.FromERP/IcsAutoSyncMoRoute_Rhtyon.cs
  4. 2
      ICSSoft.Test/ICSSoft.Test.csproj

BIN
.vs/ICSSoft.FromERP/v16/.suo

Binary file not shown.

1
ICSSoft.FromERP/ICSSoft.FromERP.csproj

@ -93,6 +93,7 @@
<Compile Include="IcsAutoMo2Lot4JWX.cs" />
<Compile Include="IcsAutoSyncItemRoute.cs" />
<Compile Include="IcsAutoSyncMoRoute.cs" />
<Compile Include="IcsAutoSyncMoRoute_Rhtyon.cs" />
<Compile Include="ICSDeliveryNotice.cs" />
<Compile Include="ICSDisassemblyDoc.cs" />
<Compile Include="ICSICSMOIssue.cs" />

104
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
{
/// <summary>
/// 工单工艺自动生成(锐腾)
/// </summary>
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<string> itemCodeList = new List<string>() { "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());
}
}
}
}

2
ICSSoft.Test/ICSSoft.Test.csproj

@ -94,7 +94,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ICSSoft.FromERP\ICSSoft.FromERP.csproj">
<Project>{71BE770C-F5BE-46C8-A81C-1897E28DB761}</Project>
<Project>{71be770c-f5be-46c8-a81c-1897e28db761}</Project>
<Name>ICSSoft.FromERP</Name>
</ProjectReference>
</ItemGroup>

Loading…
Cancel
Save