Browse Source
Merge branch 'master' of http://119.3.29.177:3000/xusc/IcsFromERPJob
Branch_PaiNaWeiSJob
Merge branch 'master' of http://119.3.29.177:3000/xusc/IcsFromERPJob
Branch_PaiNaWeiSJob
shiqian.wang
2 days ago
7 changed files with 189 additions and 7 deletions
-
BIN.vs/ICSSoft.FromERP/v16/.suo
-
4ICSSoft.FromERP/App.config
-
1ICSSoft.FromERP/ICSSoft.FromERP.csproj
-
13ICSSoft.FromERP/IcsMo_Rhtyon.cs
-
2ICSSoft.FromERP/SyncCas_Jinyang.cs
-
174ICSSoft.FromERP/SyncMoHour_Rhyton.cs
-
2ICSSoft.Test/Program.cs
Binary file not shown.
@ -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 |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 工单工时统计(锐腾)
|
||||
|
/// </summary>
|
||||
|
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()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue