Browse Source

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

Branch_PaiNaWeiSJob
shiqian.wang 3 months ago
parent
commit
e56d39d44d
  1. BIN
      .vs/ICSSoft.FromERP/v16/.suo
  2. 4
      ICSSoft.FromERP/App.config
  3. 1
      ICSSoft.FromERP/ICSSoft.FromERP.csproj
  4. 159
      ICSSoft.FromERP/IcsMainCategoryCode_Rhtyon.cs
  5. 2
      ICSSoft.Test/Program.cs

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

Binary file not shown.

4
ICSSoft.FromERP/App.config

@ -18,9 +18,9 @@
</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;"/>
<!--<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"/>
<add name="MailOpen" connectionString="true"/>
<add name="SendHost" connectionString="mail.huahengweld.com"/>

1
ICSSoft.FromERP/ICSSoft.FromERP.csproj

@ -102,6 +102,7 @@
<Compile Include="ICSInventory_Rhtyon.cs" />
<Compile Include="IcsMainCategoryCodeFromU8.cs" />
<Compile Include="IcsMainCategoryCode.cs" />
<Compile Include="IcsMainCategoryCode_Rhtyon.cs" />
<Compile Include="ICSManufactureReceive.cs" />
<Compile Include="ICSMoBom.cs" />
<Compile Include="ICSModel.cs" />

159
ICSSoft.FromERP/IcsMainCategoryCode_Rhtyon.cs

@ -0,0 +1,159 @@
using Quartz;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace ICSSoft.FromERP
{
/// <summary>
/// 物料分类(锐腾)
/// </summary>
public class IcsMainCategoryCode_Rhtyon : 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;
DataTable dt = ICSHelper.GetERPDB(conStr);
foreach (DataRow dr in dt.Rows)
{
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);
#region SQL
string sql = @" select a.code as ItemMainCategoryCode
,b.Name as ItemMainCategoryName
,b.Description as ItemMainCategoryDesc
,a.ModifiedOn MTime
,I.id as Org
,p.parentCode
,a.DescFlexField_PrivateDescSeg1
,a.DescFlexField_PrivateDescSeg2
,a.DescFlexField_PrivateDescSeg3
,a.DescFlexField_PrivateDescSeg4
INTO #TempItemCategory
from {1}.dbo.[CBO_Category] a
left join {1}.dbo.CBO_CategoryType catt on catt.id=a.CategorySystem
left join {1}.dbo.[CBO_Category_Trl] b on a.id=b.id AND b.SysMLFlag='zh-CN'
left join {1}.dbo.[Base_Organization] AS I ON ( A.[Org] = I.[ID] )
left join {1}.dbo.[Base_Organization_Trl] AS J ON ( I.[ID] = J.[ID] AND J.SysMLFlag='zh-CN')
left join
(
SELECT
a2.code parentCode
,a3.name parentName
, A .code
, A1.[Name]
, a.level+1
FROM {1}.dbo.Base_DefineValue AS A
LEFT JOIN {1}.dbo.[Base_DefineValue_Trl] AS A1 ON(A1.SysMlFlag = 'zh-CN') AND(A.[ID] = A1.[ID])
left join {1}.dbo.Base_DefineValue a2 on a2.id=a.ParentNode
and a2.Effective_IsEffective=1
and a2.Effective_DisableDate>= CAST ( CAST ( GETDATE( ) AS DATE ) AS VARCHAR ( 10 ) ) + ' 00:00:00'
AND a2.Effective_EffectiveDate< CAST ( CAST ( dateadd( DAY, 1, GETDATE( ) ) AS DATE ) AS VARCHAR ( 10 ) ) + ' 00:00:00'
LEFT JOIN {1}.dbo.[Base_DefineValue_Trl] AS A3 ON(A3.SysMlFlag = 'zh-CN') AND(A2.[ID] = A3.[ID])
WHERE 1=1
and A.[ValueSetDef] = (SELECT ID FROM {1}.dbo.Base_ValueSetDef_trl DD WHERE name = '' )
and a.Effective_IsEffective=1
and a.Effective_DisableDate>= CAST ( CAST ( GETDATE( ) AS DATE ) AS VARCHAR ( 10 ) ) + ' 00:00:00'
AND a.Effective_EffectiveDate< CAST ( CAST ( dateadd( DAY, 1, GETDATE( ) ) AS DATE ) AS VARCHAR ( 10 ) ) + ' 00:00:00'
--order by a.level+1, a2.code,A .code
) p ON a.code=p.code
where 1=1
and A.ModifiedOn>=@LastTime AND I.id={0}
and catt.IsStock='1'
ORDER BY A.Code
IF NOT EXISTS(SELECT * FROM #TempItemCategory)
RETURN";
sql = string.Format(sql, ErpId, erpName);
sql = ICSHelper.Time(Namespace, Class, TenantId, sql, "#TempItemCategory");
sql += @"--删除数据
-- DELETE ICSINVENTORY WHERE ItemCode NOT IN (SELECT cInvCode FROM {1}.dbo.[CBO_ItemMaster])
SELECT a.ItemMainCategoryCode INTO #tableItemCategory
FROM IcsMainCategoryCode a With(NoLock)
LEFT JOIN {1}.dbo.[CBO_Category] b With(NoLock) ON a.ItemMainCategoryCode=b.Code
WHERE b.code is null
and a.TenantId='{0}'
AND b.Org={2}
DELETE IcsMainCategoryCode
WHERE TenantId='{0}' and ItemMainCategoryCode IN ( SELECT ItemMainCategoryCode from #tableItemCategory) ";
Dictionary<string, string> values = new Dictionary<string, string>();
values.Add("ItemMainCategoryCode", "a.ItemMainCategoryCode");//物料编号
values.Add("ItemMainCategoryName", "a.ItemMainCategoryNAME");//物料名称
values.Add("ItemMainCategoryDesc", "a.ItemMainCategoryDesc");//物料描述
values.Add("LastModificationTime", "a.MTime");//操作时间
values.Add("PCode", "a.parentCode");//操作人
values.Add("Default1", "a.DescFlexField_PrivateDescSeg1");//操作人
values.Add("Default2", "a.DescFlexField_PrivateDescSeg2");//操作人
values.Add("Default3", "a.DescFlexField_PrivateDescSeg3");//操作人
values.Add("Default4", "a.DescFlexField_PrivateDescSeg4");//操作人
//更新存在数据
sql += ICSHelper.UpdateSQL("b", values)
+ @" #TempItemCategory a
INNER JOIN IcsMainCategoryCode b ON a.ItemMainCategoryCode=b.ItemMainCategoryCode
WHERE b.TenantId='" + TenantId + "' and a.Org={2}";
values.Add("CreationTime", "a.MTime");//操作人
values.Add("CreatorUserId", "'" + ConstWorkPoint.Muser + "'");//操作人
values.Add("CreatorUserName", "'" + ConstWorkPoint.Musername + "'");//操作人名称
values.Add("TenantId", "'" + TenantId + "'");//站点
//插入新增数据
sql += ICSHelper.InsertSQL("IcsMainCategoryCode", values)
+ @" #TempItemCategory a
LEFT JOIN IcsMainCategoryCode b ON a.ItemMainCategoryCode=b.ItemMainCategoryCode and b.TenantId='{0}'
WHERE 1=1 and b.ItemMainCategoryCode is null
and a.Org={2}
";
sql += " DROP TABLE #TempItemCategory " +
" DROP TABLE #tableItemCategory ";
sql = string.Format(sql, TenantId, erpName, ErpId);
// return;
ICSHelper.ExecuteDate(conStr, sql);
#endregion
}
}
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();
SyncCas_Jinyang test = new SyncCas_Jinyang();
IcsMainCategoryCode_Rhtyon test = new IcsMainCategoryCode_Rhtyon();
test.Execute();
// var ss= ICSHelper.ApiSign("sj_w_id", "70FF7F01C5899A5ACAAD4ECB7FA5B3C5", 1724650261);

Loading…
Cancel
Save