Browse Source

Merge branch 'master' of http://119.3.29.177:3000/xusc/IcsFromERPJob

Branch_PaiNaWeiSJob
shiqian.wang 1 day ago
parent
commit
634326ce0c
  1. BIN
      .vs/ICSSoft.FromERP/v16/.suo
  2. 4
      ICSSoft.FromERP/App.config
  3. 1
      ICSSoft.FromERP/ICSSoft.FromERP.csproj
  4. 13
      ICSSoft.FromERP/IcsMo_Rhtyon.cs
  5. 2
      ICSSoft.FromERP/SyncCas_Jinyang.cs
  6. 174
      ICSSoft.FromERP/SyncMoHour_Rhyton.cs
  7. 2
      ICSSoft.Test/Program.cs

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

Binary file not shown.

4
ICSSoft.FromERP/App.config

@ -2,7 +2,8 @@
<configuration>
<appSettings>
<!--<add key="ERPDB" value="[U9Ctest]"/>-->
<add key="ERPDB" value="[192.168.93.132].[U9TEST0628]"/>
<!--<add key="ERPDB" value="[192.168.93.132].[U9TEST0628]"/>-->
<add key="ERPDB" value="[192.168.93.133].[U9RTDB]"/>
<add key="Workpoint_ERPDB" value="zhc|[MESTOU8].[UFDATA_001_2017]"/>
<!--token 地址-->
<add key="WeiMasTokenUrl" value="https://test.zhangsanfeng.vip"/>
@ -18,6 +19,7 @@
</appSettings>
<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_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;"/>-->

1
ICSSoft.FromERP/ICSSoft.FromERP.csproj

@ -177,6 +177,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>

13
ICSSoft.FromERP/IcsMo_Rhtyon.cs

@ -63,7 +63,9 @@ namespace ICSSoft.FromERP
0 as RCVQuantity,
A13.Code as DepCode,
A22.Code as WHCode,
'mostatus_initial' as MOStatus,
case when A.DocState=2 then 'mostatus_initial'
when A.DocState=3 then 'mostatus_close'
else 'mostatus_initial' end as MOStatus,
A2.Description as MOMemo,
'2' as ERPStatus,
A.StartDate as StartDate,
@ -85,6 +87,7 @@ namespace ICSSoft.FromERP
,A12.Code as TenantId
,A12.id as Org
,a.DescFlexField_PrivateDescSeg1 AS EATTRIBUTE1
,a.DescFlexField_PrivateDescSeg2 AS EATTRIBUTE2
,(
select b1.code from {1}.dbo.UBF_Sys_ExtEnumType a1
left join {1}.dbo.UBF_Sys_ExtEnumValue b1 on a1.ID=b1.ExtEnumType
@ -170,11 +173,11 @@ else Convert(varchar(10),a.ActualCompleteDate,120 ) end as ActualCompleteDate
values.Add("LastModifierUserId", "'" + ConstWorkPoint.Muser + "'");
values.Add("LastModifierUserName", "'" + ConstWorkPoint.Musername + "'");
values.Add("LastModificationTime", "a.Mtime");//操作时间
//values.Add("Default1", "a.EATTRIBUTE1");
//values.Add("Default2", "a.NeedType");
values.Add("Default1", "a.EATTRIBUTE1");
values.Add("CusItemCode", "a.EATTRIBUTE2");
values.Add("DocType", "a.MoDocType");
// values.Add("Default3", "a.ActualCompleteDate");
// values.Add("Default3", "a.ActualCompleteDate");
//更新存在数据
sql += ICSHelper.UpdateSQL("b", values)
+ @" #TempMO a

2
ICSSoft.FromERP/SyncCas_Jinyang.cs

@ -67,6 +67,8 @@ DROP TABLE #tempSyncCas_Jinyang
select * ,a.CreateTime as MTime into #tempSyncCas_Jinyang from [ICSDomeAmb] a with( nolock)
where a.CreateTime>@LastTime
and free1 <>'15' and Free2 not like '%e%' and free1<>'0'
and LotNO <>''
select
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)
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());
}
}
}
}

2
ICSSoft.Test/Program.cs

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

Loading…
Cancel
Save