xusc 2 months ago
parent
commit
b9feee0b8b
  1. BIN
      .vs/ICSSoft.FromERP/v16/.suo
  2. 1
      ICSSoft.FromERP/ICSSoft.FromERP.csproj
  3. 122
      ICSSoft.FromERP/IcsAutoMo2Lot4JWX.cs
  4. 2
      ICSSoft.FromERP/IcsAutoSyncMoRoute.cs
  5. 41
      ICSSoft.FromERP/SyncMoHour_Rhyton.cs

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

Binary file not shown.

1
ICSSoft.FromERP/ICSSoft.FromERP.csproj

@ -91,7 +91,6 @@
<Compile Include="Helper\HttpHelper.cs" />
<Compile Include="ICSAddStdWorkHourFromMES.cs" />
<Compile Include="IcsAutoMo2Lot.cs" />
<Compile Include="IcsAutoMo2Lot4JWX.cs" />
<Compile Include="IcsAutoSyncItemRoute.cs" />
<Compile Include="IcsAutoSyncMoRoute.cs" />
<Compile Include="IcsAutoSyncMoRoute_Rhtyon.cs" />

122
ICSSoft.FromERP/IcsAutoMo2Lot4JWX.cs

@ -1,122 +0,0 @@
using NFine.Data.Extensions;
using Quartz;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace ICSSoft.FromERP
{
public class IcsAutoMo2Lot4JWX : 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();
var sql0 = @"select RuleCode,a.Prefix,a.Suffix,a.DateCode,a.SerialLength,a.RuleSeq
from SysLabelRule a with(nolock) where RuleCode='Mo2Lot' and TenantId='" + TenantId + "' ";
var ruleDt = ICSHelper.ExecuteTable(conStr, sql0);
if (ruleDt == null || ruleDt.Rows.Count == 0)
{
return;
}
string sql1 = @" select a.MoCode,a.MoSeq
,a.Id
,a.MoPlanQty
from IcsMo a with(nolock) where
exists (
select ItemCode from IcsManufacturingHead t with(nolock) where (ContractNo like 'NK%' OR ContractNo like 'FW%')
and t.ItemCode=a.ItemCode
)
and a.MoPlanQty>0
and not exists (select MoCode from IcsMo2Lot with(nolock) where MoCode=a.MoCode)
and TenantId='" + TenantId + "' ";
var itemDt = ICSHelper.ExecuteTable(conStr, sql1);//生产工单
if (itemDt != null && itemDt.Rows.Count > 0)
{
string sql2 = "";
foreach (DataRow dr2 in itemDt.Rows)
{
var qty = dr2["MoPlanQty"].ToInt();
var sql4 = "";
//更新工单表
sql2 += @"
update icsmo
set MoStatus='mostatus_release',LastModificationTime=GETDATE(),LastModifierUserId='c65321b94c804dc26eb93a0ba67c8a2a',LastModifierUserName='xusc'
where Id=" + dr2["Id"].ToInt64() + " and MoStatus='mostatus_initial' and TenantId='" + TenantId + "' ";
for (int i = 0; i < qty; i++)
{
//查询序列号
var sql3 = @"
EXEC Addins_GetSerialCode '" + TenantId + "','IcsMo2Lot','Lotno','" + ruleDt.Rows[0]["Prefix"].ToString() + "','" + ruleDt.Rows[0]["Suffix"].ToString() + "','" + DateTime.Now.ToString(ruleDt.Rows[0]["DateCode"].ToString()) + "'," + ruleDt.Rows[0]["SerialLength"].ToInt() + ",'" + ruleDt.Rows[0]["RuleSeq"].ToStringExt() + "'";
var lotno = ICSHelper.ExecuteScalar(conStr, sql3).ToStringExt();
sql4 += @"
insert into IcsMo2Lot (MoId,MoCode,MoSeq,Lotno,LotSeq,LotQty,LotStatus,PrintTimes,TenantId,CreationTime,CreatorUserId,CreatorUserName)
select " + dr2["Id"].ToInt64() + ",'" + dr2["MoCode"].ToStringExt() + "'," + dr2["MoSeq"].ToInt64() + ",'" + lotno + "',1," + dr2["MoPlanQty"].ToDecimal() + ",'lotstatus_new',0,'" + TenantId + "',GETDATE(),'c65321b94c804dc26eb93a0ba67c8a2a','xusc'";
}
ICSHelper.ExecuteDate(conStr, sql4);//批量更新批次(单个工单)
}
ICSHelper.ExecuteDate(conStr, sql2);//批量更新工单
}
}
}
catch (Exception ex)
{
log.Error(ex.ToString());
}
}
}
}

2
ICSSoft.FromERP/IcsAutoSyncMoRoute.cs

@ -59,7 +59,7 @@ namespace ICSSoft.FromERP
foreach (var item in dis)
{
string sql1 = @" select a.MoCode,a.MoSeq, a.Id from IcsMo a with(nolock)
where a.ItemCode like '" + item.Key+ "%' and not exists (select MoCode from IcsMo2Route with(nolock) where MoCode=a.MoCode) and TenantId='" + TenantId + "' ";
where a.ItemCode like '" + item.Key+ "%' and a.MoCode like 'MOSCZP%' and not exists (select MoCode from IcsMo2Route with(nolock) where MoCode=a.MoCode) and TenantId='" + TenantId + "' ";
var itemDt = ICSHelper.ExecuteTable(conStr, sql1);
if (itemDt != null && itemDt.Rows.Count > 0)

41
ICSSoft.FromERP/SyncMoHour_Rhyton.cs

@ -60,10 +60,13 @@ namespace ICSSoft.FromERP
lastDate = dtNowBegin;
}
string sql = @" if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempSyncMoHour_Rhyton') and type='U')
string sql = @"
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempSyncMoHour_Rhyton') and type='U')
DROP TABLE #tempSyncMoHour_Rhyton
--
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempSyncMoHourYesData_Rhyton') and type='U')
DROP TABLE #tempSyncMoHourYesData_Rhyton
select
a.MoCode
@ -139,6 +142,10 @@ order by a.MoCode, a.OpSeq asc
delete from IcsMoHourData
where Status='No'
select * into #tempSyncMoHourYesData_Rhyton from IcsMoHourData
where Status='Yes'
truncate table IcsMoHourData
insert into IcsMoHourData (
MoCode
@ -157,6 +164,36 @@ where Status='No'
select a.* from #tempSyncMoHour_Rhyton a
left join IcsMoHourData b with(nolock) on a.MoCode=b.MoCode and a.OpCode=b.OpCode
where b.MoCode is null and b.OpCode is null
insert into IcsMoHourData (
MoCode
,ItemCode
,OpCode
,Qty
,STime
,RealTime
,ManualTime
,AlterTime
,Status
,TenantId
,CreationTime
,CreatorUserId
,CreatorUserName
,VerifyUser
,VerifyDate
,LastModificationTime
,LastModifierUserId
,LastModifierUserName
)
select a.MoCode,a.ItemCode,a.OpCode,a.Qty,a.STime,a.RealTime,a.ManualTime
,a.AlterTime
,a.Status,a.TenantId
,a.CreationTime,a.CreatorUserId,a.CreatorUserName,a.VerifyUser,a.VerifyDate
,a.LastModificationTime,a.LastModifierUserId,a.LastModifierUserName
from #tempSyncMoHourYesData_Rhyton a
";
sql = string.Format(sql, TenantId);

Loading…
Cancel
Save