Browse Source

锐腾 工单工时同步

master
xusc 2 months ago
parent
commit
9af71c3d83
  1. BIN
      .vs/ICSSoft.FromERP/v16/.suo
  2. 2
      ICSSoft.FromERP/App.config
  3. 1
      ICSSoft.FromERP/ICSSoft.FromERP.csproj
  4. 4
      ICSSoft.FromERP/IcsMo_Rhtyon.cs
  5. 174
      ICSSoft.FromERP/SyncMoHour_Rhyton.cs
  6. 2
      ICSSoft.Test/Program.cs

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

Binary file not shown.

2
ICSSoft.FromERP/App.config

@ -20,7 +20,7 @@
<connectionStrings>
<!--<add name="SysConnectionString" connectionString="Data Source=119.3.29.177;Database=ICSMESBase;Uid=gitea;Pwd=aA123456;"/>-->
<!--<add name="SysConnectionString" connectionString="server=192.168.93.135; Database=ICSMESBase_RuiTeng; User ID=sa; Password=rhyt0n***;MultipleActiveResultSets=True;Connect Timeout=300;"/>-->
<add name="SysConnectionString" connectionString="server=192.168.93.135; Database=ICSMESBase_RuiTengZS; User ID=sa; Password=rhyt0n***;MultipleActiveResultSets=True;Connect Timeout=300;"/>
<add name="SysConnectionString" connectionString="server=192.168.93.135; Database=ICSMESBase_RuiTeng; User ID=sa; Password=rhyt0n***;MultipleActiveResultSets=True;Connect Timeout=300;"/>
<!--<add name="SysConnectionString" connectionString="server=192.168.1.155; Database=ICSMESBase_WeiMas; User ID=sa; Password=aA123456;MultipleActiveResultSets=True;Connect Timeout=300;"/>-->
<!--<add name="SysConnectionString" connectionString="server=172.16.12.201; Database=ICSJYMES; User ID=sa; Password=aA123456;MultipleActiveResultSets=True;Connect Timeout=300;"/>-->
<add name="APIAddStdWorkHour" connectionString="http://192.168.1.110:9097/api/APIAddStdWorkHour"/>

1
ICSSoft.FromERP/ICSSoft.FromERP.csproj

@ -175,6 +175,7 @@
<Compile Include="SyncCas_Jinyang.cs" />
<Compile Include="SyncCustomer_WeiMas.cs" />
<Compile Include="SyncItem_WeiMas.cs" />
<Compile Include="SyncMoHour_Rhyton.cs" />
<Compile Include="SyncVendor_WeiMas.cs" />
<Compile Include="XmlAPIHelper.cs" />
</ItemGroup>

4
ICSSoft.FromERP/IcsMo_Rhtyon.cs

@ -176,7 +176,7 @@ else Convert(varchar(10),a.ActualCompleteDate,120 ) end as ActualCompleteDate
//values.Add("Default2", "a.NeedType");
values.Add("DocType", "a.MoDocType");
// values.Add("Default3", "a.ActualCompleteDate");
values.Add("MOSTATUS", "a.MOStatus");//生产订单状态
//更新存在数据
sql += ICSHelper.UpdateSQL("b", values)
+ @" #TempMO a
@ -198,7 +198,7 @@ else Convert(varchar(10),a.ActualCompleteDate,120 ) end as ActualCompleteDate
values.Add("CreatorUserId", "'" + ConstWorkPoint.Muser + "'");//操作人
values.Add("CreatorUserName", "'" + ConstWorkPoint.Musername + "'");//操作人名称
values.Add("TenantId", "'" + TenantId + "'");//站点
values.Add("MOSTATUS", "a.MOStatus");//生产订单状态
//插入新增数据
sql += ICSHelper.InsertSQL("ICSMO", values)
+ @" #TempMO a

174
ICSSoft.FromERP/SyncMoHour_Rhyton.cs

@ -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)
left join IcsInventory b with(nolock) on a.ItemCode=b.ItemCode and a.TenantId=b.TenantId
left join IcsMo2Route d with(nolock) on a.MoCode=d.MoCode and d.IsMRoute='Y' and a.TenantId=d.TenantId
left join IcsMoRoute2Op e with(nolock) on d.MoCode=e.MoCode and d.RouteId=e.RouteId and d.TenantId=e.TenantId
left 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());
}
}
}
}

2
ICSSoft.Test/Program.cs

@ -13,7 +13,7 @@ namespace ICSSoft.Test
//ICSVendor test = new ICSVendor();
//test.Execute();
IcsMo_Rhtyon test = new IcsMo_Rhtyon();
SyncMoHour_Rhyton test = new SyncMoHour_Rhyton();
test.Execute();
// var ss= ICSHelper.ApiSign("sj_w_id", "70FF7F01C5899A5ACAAD4ECB7FA5B3C5", 1724650261);

Loading…
Cancel
Save