diff --git a/.vs/ICSSoft.FromERP/v16/.suo b/.vs/ICSSoft.FromERP/v16/.suo
index f39d84e..ff3ab15 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 770c2cf..f3bd839 100644
--- a/ICSSoft.FromERP/ICSSoft.FromERP.csproj
+++ b/ICSSoft.FromERP/ICSSoft.FromERP.csproj
@@ -91,7 +91,6 @@
-
diff --git a/ICSSoft.FromERP/IcsAutoMo2Lot4JWX.cs b/ICSSoft.FromERP/IcsAutoMo2Lot4JWX.cs
deleted file mode 100644
index d4c23f5..0000000
--- a/ICSSoft.FromERP/IcsAutoMo2Lot4JWX.cs
+++ /dev/null
@@ -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 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();
-
- 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());
- }
- }
- }
-}
diff --git a/ICSSoft.FromERP/IcsAutoSyncMoRoute.cs b/ICSSoft.FromERP/IcsAutoSyncMoRoute.cs
index bbdd3b7..b694b2e 100644
--- a/ICSSoft.FromERP/IcsAutoSyncMoRoute.cs
+++ b/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)
diff --git a/ICSSoft.FromERP/SyncMoHour_Rhyton.cs b/ICSSoft.FromERP/SyncMoHour_Rhyton.cs
index 9261a7c..e94cc1e 100644
--- a/ICSSoft.FromERP/SyncMoHour_Rhyton.cs
+++ b/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);