shiqian.wang
3 months ago
11 changed files with 1817 additions and 0 deletions
-
13ICSSoft.FromERP/ICSSoft.FromERP.csproj
-
156ICSSoft.FromERP/RestOpHelper.cs
-
232ICSSoft.FromERP/SK/YERP_001.cs
-
213ICSSoft.FromERP/SK/YERP_005.cs
-
244ICSSoft.FromERP/SK/YERP_007.cs
-
169ICSSoft.FromERP/SK/YERP_008.cs
-
177ICSSoft.FromERP/SK/YERP_010_BOH.cs
-
178ICSSoft.FromERP/SK/YERP_010_EOH.cs
-
146ICSSoft.FromERP/SK/YERP_011.cs
-
178ICSSoft.FromERP/SK/YERP_012.cs
-
111ICSSoft.FromERP/XmlAPIHelper.cs
@ -0,0 +1,156 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net.Security; |
||||
|
using System.Net; |
||||
|
using System.Security.Cryptography.X509Certificates; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace ICSSoft.FromERP |
||||
|
{ |
||||
|
public class RestOpHelper |
||||
|
{ |
||||
|
private string url = ""; |
||||
|
|
||||
|
public string Url |
||||
|
{ |
||||
|
get { return url; } |
||||
|
set { url = value; } |
||||
|
} |
||||
|
private string clientp12path = ""; |
||||
|
|
||||
|
public string Clientp12path |
||||
|
{ |
||||
|
get { return clientp12path; } |
||||
|
set { clientp12path = value; } |
||||
|
} |
||||
|
private string clientp12PassWord = ""; |
||||
|
|
||||
|
public string Clientp12PassWord |
||||
|
{ |
||||
|
get { return clientp12PassWord; } |
||||
|
set { clientp12PassWord = value; } |
||||
|
} |
||||
|
public RestOpHelper() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
public string send(string s) |
||||
|
{ |
||||
|
string retrunstr = ""; |
||||
|
//类似浏览器确认证书合法方法的绑定
|
||||
|
//如果觉得写一个委托方法麻烦,可以直接使用匿名委托
|
||||
|
ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidate; |
||||
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; |
||||
|
Uri uri = new Uri(@url); |
||||
|
HttpWebRequest request = HttpWebRequest.Create(uri) as HttpWebRequest; |
||||
|
byte[] bs = Encoding.UTF8.GetBytes(s); |
||||
|
|
||||
|
//这2句代码表示如果要求客户端证书,将客户端证书加入request,不需要客户端证书的https请求则不需要此代码 //需导入xx.p12证书文件 clientp12path为文件所在路径clientp12password为证书密码 InstallCertificate(clientp12path, clientp12PassWord, StoreLocation.CurrentUser, StoreName.My);
|
||||
|
X509Certificate cer = new X509Certificate(clientp12path, clientp12PassWord); |
||||
|
|
||||
|
request.Credentials = new NetworkCredential("IF_YERP", "Xtxc355860"); |
||||
|
request.AuthenticationLevel = AuthenticationLevel.MutualAuthRequested; |
||||
|
//request.
|
||||
|
request.Timeout = 10000; |
||||
|
request.ClientCertificates.Add(cer); |
||||
|
request.ContentType = "text/plain"; |
||||
|
request.Method = "post"; |
||||
|
request.KeepAlive = false; |
||||
|
request.ProtocolVersion = HttpVersion.Version10; |
||||
|
request.Proxy = null; |
||||
|
//request.UserAgent = DefaultUserAgent;
|
||||
|
using (Stream reqStram = request.GetRequestStream()) |
||||
|
{ |
||||
|
reqStram.Write(bs, 0, bs.Length); |
||||
|
reqStram.Close(); |
||||
|
} |
||||
|
|
||||
|
HttpWebResponse response = request.GetResponse() as HttpWebResponse; |
||||
|
using (StreamReader reader = new StreamReader(response.GetResponseStream())) |
||||
|
{ |
||||
|
retrunstr = reader.ReadToEnd(); |
||||
|
} |
||||
|
return retrunstr; |
||||
|
} |
||||
|
private static bool RemoteCertificateValidate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) |
||||
|
{ |
||||
|
// trust any certificate!!!
|
||||
|
//System.Console.WriteLine("Warning, trust any certificate");
|
||||
|
//为了通过证书验证,总是返回true
|
||||
|
return true; |
||||
|
} |
||||
|
//导入证书
|
||||
|
public static bool InstallCertificate(string certFilePath, string password, StoreLocation location, StoreName storeName) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (!File.Exists(certFilePath)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
byte[] certData = File.ReadAllBytes(certFilePath); |
||||
|
X509Certificate2 cert = new X509Certificate2(certData, password, X509KeyStorageFlags.Exportable); |
||||
|
X509Store store = new X509Store(storeName, location); |
||||
|
store.Open(OpenFlags.MaxAllowed); |
||||
|
store.Remove(cert); |
||||
|
store.Add(cert); |
||||
|
store.Close(); |
||||
|
return true; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public void RequestSAP(string url, int timeout, string xmlData, string userName, string password, out string statusCode, out string resultContent) |
||||
|
{ |
||||
|
statusCode = "400"; |
||||
|
resultContent = ""; |
||||
|
try |
||||
|
{ |
||||
|
byte[] bytes = Encoding.UTF8.GetBytes(xmlData); |
||||
|
|
||||
|
//Basic Auth
|
||||
|
byte[] byteUser = Encoding.Default.GetBytes(userName + ":" + password); |
||||
|
string Authorization = Convert.ToBase64String(byteUser); |
||||
|
|
||||
|
HttpWebRequest request = HttpWebRequest.CreateHttp(url); |
||||
|
|
||||
|
//这2句代码表示如果要求客户端证书,将客户端证书加入request,不需要客户端证书的https请求则不需要此代码 //需导入xx.p12证书文件 clientp12path为文件所在路径clientp12password为证书密码 InstallCertificate(clientp12path, clientp12PassWord, StoreLocation.CurrentUser, StoreName.My);
|
||||
|
X509Certificate cer = new X509Certificate(clientp12path, clientp12PassWord); |
||||
|
request.ClientCertificates.Add(cer); |
||||
|
|
||||
|
//避免远程连接证书无效问题
|
||||
|
ServicePointManager.ServerCertificateValidationCallback = (s, certificate, chain, errs) => true; |
||||
|
request.Method = "POST"; |
||||
|
request.Timeout = timeout; |
||||
|
request.ContentType = "text/xml;charset=UTF-8"; |
||||
|
request.ContentLength = bytes.Length; |
||||
|
request.Headers.Add("Authorization", "Basic " + Authorization); |
||||
|
//根据soapui中的SOAPAction 进行赋值
|
||||
|
request.Headers.Add("SOAPAction", "SOAPAction"); |
||||
|
Stream requestStream = request.GetRequestStream(); |
||||
|
requestStream.Write(bytes, 0, bytes.Length); |
||||
|
HttpWebResponse response = request.GetResponse() as HttpWebResponse; |
||||
|
statusCode = response.StatusCode.ToString("d"); |
||||
|
Stream responseStream = response.GetResponseStream(); |
||||
|
StreamReader sr = new StreamReader(responseStream, Encoding.UTF8); |
||||
|
resultContent = sr.ReadToEnd(); |
||||
|
sr.Dispose(); |
||||
|
requestStream.Close(); |
||||
|
responseStream.Close(); |
||||
|
response.Dispose(); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
statusCode = "400"; |
||||
|
resultContent = ex.Message; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,232 @@ |
|||||
|
using Quartz; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Data; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Reflection; |
||||
|
using System.Text; |
||||
|
using System.Text.RegularExpressions; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace ICSSoft.FromERP |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 进销存统计表
|
||||
|
/// </summary>
|
||||
|
public class YERP_001 : 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 async void Execute() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
Configuration config = GetConfig(); |
||||
|
//string url = config.ConnectionStrings.ConnectionStrings["APIAddStdWorkHour"].ConnectionString.ToString();
|
||||
|
|
||||
|
var Dates = DateTime.Now; |
||||
|
//log.Info("获取创建定额工时接口 " + url);
|
||||
|
//if (string.IsNullOrEmpty(url))
|
||||
|
//{
|
||||
|
// return;
|
||||
|
//}
|
||||
|
string conStr = ICSHelper.GetConnectString(); |
||||
|
//<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:yerp="http://skch.com/YERP_001_INVENTORY_DATA">
|
||||
|
// <soapenv:Header/>
|
||||
|
// <soapenv:Body>
|
||||
|
// <yerp:YERP_001_OA1_MT>
|
||||
|
// <!--1 or more repetitions:-->
|
||||
|
// <INVT_DATA>
|
||||
|
// <YYYY_MM_DD>2024-08-20</YYYY_MM_DD>
|
||||
|
// <INVT_NM>BR8040</INVT_NM>
|
||||
|
// <INVT_CD>103016</INVT_CD>
|
||||
|
// <BSC_QTY>0.00</BSC_QTY>
|
||||
|
// <BSC_AMT>0.00</BSC_AMT>
|
||||
|
// <PCHS_QTY>15000.00</PCHS_QTY>
|
||||
|
// <PCHS_AMT>245870.26</PCHS_AMT>
|
||||
|
// <ESTM_QTY>0.00</ESTM_QTY>
|
||||
|
// <ESTM_AMT>0.00</ESTM_AMT>
|
||||
|
// <ETC_WHG_QTY>8305.00</ETC_WHG_QTY>
|
||||
|
// <ETC_WHG_AMT>157592.50</ETC_WHG_AMT>
|
||||
|
// <ETC_RLS_QTY>8388.00</ETC_RLS_QTY>
|
||||
|
// <ETC_RLS_AMT>151226.81</ETC_RLS_AMT>
|
||||
|
// <MOVE_QTY>0.00</MOVE_QTY>
|
||||
|
// <MOVE_AMT>0.00</MOVE_AMT>
|
||||
|
// <SL_QTY>6450.0000</SL_QTY>
|
||||
|
// <SL_RVN>102513.2100</SL_RVN>
|
||||
|
// <SL_AMT>115839.8800</SL_AMT>
|
||||
|
// <FRTX_AVRG_PRC>0</FRTX_AVRG_PRC>
|
||||
|
// <SMTX_AVRG_PRC>0</SMTX_AVRG_PRC>
|
||||
|
// <RLS_QTY>6450.00</RLS_QTY>
|
||||
|
// <SL_COST>108183.8000</SL_COST>
|
||||
|
// <SLS_TOT_GAIN>-5670.59</SLS_TOT_GAIN>
|
||||
|
// <SLS_TOT_PRTO>?</SLS_TOT_PRTO>
|
||||
|
// <TE_QTY>8467.00</TE_QTY>
|
||||
|
// <TE_AMT>144052.15</TE_AMT>
|
||||
|
// </INVT_DATA>
|
||||
|
// </yerp:YERP_001_OA1_MT>
|
||||
|
// </soapenv:Body>
|
||||
|
// </soapenv:Envelope>
|
||||
|
// 202404
|
||||
|
// 过滤时间为上个月
|
||||
|
string Date = "2023";// Dates.ToString("yyyy");
|
||||
|
string Muoth = Dates.AddMonths(-1).ToString("MM"); |
||||
|
string Day = Dates.ToString("dd"); |
||||
|
var beginPeriod = "2023-01-01";//Date + Muoth;
|
||||
|
var endPeriod = "2023-12-31";//Date + Muoth;
|
||||
|
string sqls = @"
|
||||
|
begin transaction |
||||
|
|
||||
|
exec Sa_MoveSRMDetail N'JXCASKALL',N' ',N'{0}',N'{1}',N'{2}',N' ',N' ',N' ',N' ',N'' |
||||
|
|
||||
|
select identity(int,0,1) as baseid,isnull([存货名称],'') as [存货名称],isnull([规格型号],'') as [规格型号],isnull([存货编码],'') as [存货编码],(Convert(Decimal(38,2),SUM([cInvDefine12]))) as [cInvDefine12],(Convert(Decimal(38,2),SUM([cInvDefine11]))) as |
||||
|
[cInvDefine11],Convert(Decimal(38,2),SUM(isnull([期初金额],0)+isnull([采购金额],0)+isnull([其他入库金额],0)-isnull([销售成本],0)-isnull([其他出库金额],0))) as [期末金额],Convert(Decimal(38,2),SUM(isnull([期初数量],0)+isnull([采购数量],0)+isnull([其他入库数量],0)-isnull([其他出库数量],0)-isnull([出库数量],0))) as [期末数量],(Convert(Decimal(38,4),SUM([销售收入]))) as [销售收入],(Convert(Decimal(38,4),SUM([销售成本]))) as [销售成本],Convert(Decimal(38,2),SUM(isnull([销售收入],0)-isnull([销售成本],0))) as [毛利],(Convert(Decimal(38,2),SUM([出库数量]))) as [出库数量],(Convert(Decimal(38,4),SUM([销售金额]))) as [销售金额],(Convert(Decimal(38,4),SUM([销售数量]))) as [销售数量],(Convert(Decimal(38,2),SUM([调拨金额]))) as [调拨金额],(Convert(Decimal(38,2),SUM([调拨数量]))) as [调拨数量],(Convert(Decimal(38,2),SUM([其他出库金额]))) as [其他出库金额],(Convert(Decimal(38,2),SUM([其他出库数量]))) as [其他出库数量],(Convert(Decimal(38,2),SUM([其他入库金额]))) as [其他入库金额],(Convert(Decimal(38,2),SUM([其他入库数量]))) as [其他入库数量],(Convert(Decimal(38,2),SUM([暂估金额]))) as [暂估金额],(Convert(Decimal(38,2),SUM([暂估数量]))) as [暂估数量],(Convert(Decimal(38,2),SUM([采购金额]))) as [采购金额],(Convert(Decimal(38,2),SUM([采购数量]))) as [采购数量],(Convert(Decimal(38,2),SUM([期初金额]))) as [期初金额],(Convert(Decimal(38,2),SUM([期初数量]))) as [期初数量] |
||||
|
into tempdb..JXCASKALL_1 from tempdb..JXCASKALL |
||||
|
where 1 = 1 group by isnull([存货名称],''),isnull([规格型号],''),isnull([存货编码],'') |
||||
|
having isnull(sum([期初数量]),0)<> 0 or isnull(sum([采购数量]),0)<> 0 or isnull(sum([采购金额]),0) <> 0 or isnull(sum([其他入库数量]),0) <> 0 or isnull(sum([其他入库金额] ),0)<> 0 or isnull(sum([出库数量]),0)<>0 or isnull(sum([其他出库数量] ),0)<> 0 or isnull(sum([其他出库金额]),0) <> 0 or isnull(sum([期初金额]),0) <> 0 or isnull(sum([暂估数量]),0) <> 0 or isnull(sum([暂估金额] ),0)<> 0 or isnull(sum([销售数量]),0) <> 0 or isnull(sum([销售金额] ),0)<> 0 or isnull(sum([调拨数量]),0) <> 0 or isnull(sum([调拨金额]),0) <> 0 or isnull(sum([销售收入]),0) <> 0 or isnull(sum([销售成本]),0) <> 0 |
||||
|
|
||||
|
|
||||
|
|
||||
|
select A.* into TEMPDB..JXCASKALLNEW from TEMPDB..JXCASKALL A |
||||
|
inner join TEMPDB..JXCASKALL_1 sum on isnull(A.[存货名称],'')=isnull(sum.[存货名称],'') and isnull(A.[规格型号],'')=isnull(sum.[规格型号],'') and isnull(A.[存货编码],'')=isnull(sum.[存货编码],'') |
||||
|
select sum.* into TEMPDB..JXCASKALLNEW_1 from TEMPDB..JXCASKALL_1 sum |
||||
|
|
||||
|
|
||||
|
select identity(int,0,1) as index__id,* into tempdb..JXCASKALLNEW_index from |
||||
|
( select baseid +0 as baseid, [存货名称],[规格型号],[存货编码] from tempdb..JXCASKALLNEW_1)A where 1=0 |
||||
|
|
||||
|
|
||||
|
|
||||
|
insert into TEMPDB..JXCASKALLNEW_index |
||||
|
select * from (select top 1000 baseid +0 as baseid, [存货名称],[规格型号],[存货编码] |
||||
|
from TEMPDB..JXCASKALLNEW_1 order by [存货名称] asc)a |
||||
|
|
||||
|
|
||||
|
select B.index__id,a.存货名称 INVT_NM,a.存货编码 INVT_CD,a.期初数量 BSC_QTY,a.期初金额 BSC_AMT,a.采购数量 PCHS_QTY,a.采购金额 PCHS_AMT,a.暂估数量 ESTM_QTY,a.暂估金额 ESTM_AMT,a.其他入库数量 ETC_WHG_QTY, |
||||
|
a.其他入库金额 ETC_WHG_AMT,a.其他出库数量 ETC_RLS_QTY,a.其他出库金额 ETC_RLS_AMT,a.调拨数量 MOVE_QTY,a.调拨金额 MOVE_AMT,a.销售数量 SL_QTY,a.销售收入 SL_RVN,a.销售金额 SL_AMT, |
||||
|
'' FRTX_AVRG_PRC, |
||||
|
'' SMTX_AVRG_PRC, |
||||
|
a.出库数量 RLS_QTY,a.销售成本 SL_COST,a.毛利 SLS_TOT_GAIN, |
||||
|
'' SLS_TOT_PRTO,a.期末数量 TE_QTY,a.期末金额 TE_AMT |
||||
|
|
||||
|
|
||||
|
from TEMPDB..JXCASKALLNEW_1 A inner join |
||||
|
TEMPDB..JXCASKALLNEW_index B on A.baseid=B.baseid |
||||
|
|
||||
|
drop table tempdb..JXCASKALL |
||||
|
drop table tempdb..JXCASKALL_1 |
||||
|
drop table TEMPDB..JXCASKALLNEW |
||||
|
drop table TEMPDB..JXCASKALLNEW_1 |
||||
|
drop table TEMPDB..JXCASKALLNEW_index |
||||
|
|
||||
|
rollback transaction";
|
||||
|
sqls = string.Format(sqls, Date, beginPeriod, endPeriod); |
||||
|
log.Info("YERP_001 sql:" + sqls); |
||||
|
DataTable vbsdt = ICSHelper.ExecuteTable(conStr, sqls); |
||||
|
log.Info("sql结果数量" + vbsdt.Rows.Count); |
||||
|
if (vbsdt.Rows.Count > 0) |
||||
|
{ |
||||
|
StringBuilder soapRequestData = new StringBuilder(); |
||||
|
soapRequestData.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:yerp=\"http://skch.com/YERP_001_INVENTORY_DATA\">"); |
||||
|
soapRequestData.Append("<soapenv:Header/>"); |
||||
|
soapRequestData.Append("<soapenv:Body>"); |
||||
|
soapRequestData.Append("<yerp:YERP_001_OA1_MT>"); |
||||
|
//循环数据
|
||||
|
foreach (DataRow itemRow in vbsdt.Rows) |
||||
|
{ |
||||
|
//原循环部分 begin
|
||||
|
soapRequestData.Append("<INVT_DATA>"); |
||||
|
soapRequestData.Append("<YYYY_MM_DD>" + Dates.ToString("yyyy-MM-dd") + "</YYYY_MM_DD>"); |
||||
|
soapRequestData.Append(itemRow["INVT_NM"] != null ? "<INVT_NM>" + itemRow["INVT_NM"].ToString() + "</INVT_NM>" : "<INVT_NM>" + "</INVT_NM>"); |
||||
|
soapRequestData.Append(itemRow["INVT_CD"] != null ? "<INVT_CD>" + itemRow["INVT_CD"].ToString() + "</INVT_CD>" : "<INVT_CD>" + "</INVT_CD>"); |
||||
|
soapRequestData.Append(itemRow["BSC_QTY"] != null ? "<BSC_QTY>" + itemRow["BSC_QTY"].ToString() + "</BSC_QTY>" : "<BSC_QTY>" + "</BSC_QTY>"); |
||||
|
soapRequestData.Append(itemRow["BSC_AMT"] != null ? "<BSC_AMT>" + itemRow["BSC_AMT"].ToString() + "</BSC_AMT>" : "<BSC_AMT>" + "</BSC_AMT>"); |
||||
|
soapRequestData.Append(itemRow["PCHS_QTY"] != null ? "<PCHS_QTY>" + itemRow["PCHS_QTY"].ToString() + "</PCHS_QTY>" : "<PCHS_QTY>" + "</PCHS_QTY>"); |
||||
|
soapRequestData.Append(itemRow["PCHS_AMT"] != null ? "<PCHS_AMT>" + itemRow["PCHS_AMT"].ToString() + "</PCHS_AMT>" : "<PCHS_AMT>" + "</PCHS_AMT>"); |
||||
|
soapRequestData.Append(itemRow["ESTM_QTY"] != null ? "<ESTM_QTY>" + itemRow["ESTM_QTY"].ToString() + "</ESTM_QTY>" : "<ESTM_QTY>" + "</ESTM_QTY>"); |
||||
|
soapRequestData.Append(itemRow["ESTM_AMT"] != null ? "<ESTM_AMT>" + itemRow["ESTM_AMT"].ToString() + "</ESTM_AMT>" : "<ESTM_AMT>" + "</ESTM_AMT>"); |
||||
|
soapRequestData.Append(itemRow["ETC_WHG_QTY"] != null ? "<ETC_WHG_QTY>" + itemRow["ETC_WHG_QTY"].ToString() + "</ETC_WHG_QTY>" : "<ETC_WHG_QTY>" + "</ETC_WHG_QTY>"); |
||||
|
soapRequestData.Append(itemRow["ETC_WHG_AMT"] != null ? "<ETC_WHG_AMT>" + itemRow["ETC_WHG_AMT"].ToString() + "</ETC_WHG_AMT>" : "<ETC_WHG_AMT>" + "</ETC_WHG_AMT>"); |
||||
|
soapRequestData.Append(itemRow["ETC_RLS_QTY"] != null ? "<ETC_RLS_QTY>" + itemRow["ETC_RLS_QTY"].ToString() + "</ETC_RLS_QTY>" : "<ETC_RLS_QTY>" + "</ETC_RLS_QTY>"); |
||||
|
soapRequestData.Append(itemRow["ETC_RLS_AMT"] != null ? "<ETC_RLS_AMT>" + itemRow["ETC_RLS_AMT"].ToString() + "</ETC_RLS_AMT>" : "<ETC_RLS_AMT>" + "</ETC_RLS_AMT>"); |
||||
|
soapRequestData.Append(itemRow["MOVE_QTY"] != null ? "<MOVE_QTY>" + itemRow["MOVE_QTY"].ToString() + "</MOVE_QTY>" : "<MOVE_QTY>" + "</MOVE_QTY>"); |
||||
|
soapRequestData.Append(itemRow["MOVE_AMT"] != null ? "<MOVE_AMT>" + itemRow["MOVE_AMT"].ToString() + "</MOVE_AMT>" : "<MOVE_AMT>" + "</MOVE_AMT>"); |
||||
|
soapRequestData.Append(itemRow["SL_QTY"] != null ? "<SL_QTY>" + itemRow["SL_QTY"].ToString() + "</SL_QTY>" : "<SL_QTY>" + "</SL_QTY>"); |
||||
|
soapRequestData.Append(itemRow["SL_RVN"] != null ? "<SL_RVN>" + itemRow["SL_RVN"].ToString() + "</SL_RVN>" : "<SL_RVN>" + "</SL_RVN>"); |
||||
|
soapRequestData.Append(itemRow["SL_AMT"] != null ? "<SL_AMT>" + itemRow["SL_AMT"].ToString() + "</SL_AMT>" : "<SL_AMT>" + "</SL_AMT>"); |
||||
|
soapRequestData.Append(itemRow["FRTX_AVRG_PRC"] != null ? "<FRTX_AVRG_PRC>" + itemRow["FRTX_AVRG_PRC"].ToString() + "</FRTX_AVRG_PRC>" : "<FRTX_AVRG_PRC>" + "</FRTX_AVRG_PRC>"); |
||||
|
soapRequestData.Append(itemRow["SMTX_AVRG_PRC"] != null ? "<SMTX_AVRG_PRC>" + itemRow["SMTX_AVRG_PRC"].ToString() + "</SMTX_AVRG_PRC>" : "<SMTX_AVRG_PRC>" + "</SMTX_AVRG_PRC>"); |
||||
|
soapRequestData.Append(itemRow["RLS_QTY"] != null ? "<RLS_QTY>" + itemRow["RLS_QTY"].ToString() + "</RLS_QTY>" : "<RLS_QTY>" + "</RLS_QTY>"); |
||||
|
soapRequestData.Append(itemRow["SL_COST"] != null ? "<SL_COST>" + itemRow["SL_COST"].ToString() + "</SL_COST>" : "<SL_COST>" + "</SL_COST>"); |
||||
|
soapRequestData.Append(itemRow["SLS_TOT_GAIN"] != null ? "<SLS_TOT_GAIN>" + itemRow["SLS_TOT_GAIN"].ToString() + "</SLS_TOT_GAIN>" : "<SLS_TOT_GAIN>" + "</SLS_TOT_GAIN>"); |
||||
|
soapRequestData.Append(itemRow["SLS_TOT_PRTO"] != null ? "<SLS_TOT_PRTO>" + itemRow["SLS_TOT_PRTO"].ToString() + "</SLS_TOT_PRTO>" : "<SLS_TOT_PRTO>" + "</SLS_TOT_PRTO>"); |
||||
|
soapRequestData.Append(itemRow["TE_QTY"] != null ? "<TE_QTY>" + itemRow["TE_QTY"].ToString() + "</TE_QTY>" : "<TE_QTY>" + "</TE_QTY>"); |
||||
|
soapRequestData.Append(itemRow["TE_AMT"] != null ? "<TE_AMT>" + itemRow["TE_AMT"].ToString() + "</TE_AMT>" : "<TE_AMT>" + "</TE_AMT>"); |
||||
|
soapRequestData.Append("</INVT_DATA>"); |
||||
|
//原循环部分 end
|
||||
|
} |
||||
|
soapRequestData.Append("</yerp:YERP_001_OA1_MT>"); |
||||
|
soapRequestData.Append("</soapenv:Body>"); |
||||
|
soapRequestData.Append("</soapenv:Envelope>"); |
||||
|
string postData = soapRequestData.ToString(); |
||||
|
log.Info("YERP_001 xmlRequest:" + postData); |
||||
|
|
||||
|
string statusCode; |
||||
|
string resultContent; |
||||
|
|
||||
|
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072; |
||||
|
RestOpHelper rop = new RestOpHelper(); |
||||
|
rop.Clientp12path = @"C:\Users\Administrator\Desktop\yonyou-cert\wildcard.pfx"; |
||||
|
rop.Clientp12PassWord = "Yonyou2024!"; |
||||
|
rop.Url = @"https://yerp-proxy-sap-dev.skchemicals.com/XISOAPAdapter/MessageServlet?senderParty=&senderService=YERP_D&receiverParty=&receiverService=&interface=YERP_001_OA1_SI&interfaceNamespace=http://skch.com/YERP_001_INVENTORY_DATA"; |
||||
|
rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); |
||||
|
|
||||
|
log.Info("YERP_001 statusCode:" + statusCode + "\r\n" + "resultContent:" + resultContent); |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
log.Error(ex.ToString()); |
||||
|
} |
||||
|
} |
||||
|
public static Configuration GetConfig() |
||||
|
{ |
||||
|
Assembly assembly = Assembly.GetCallingAssembly(); |
||||
|
string path = string.Format("{0}.config", assembly.Location); |
||||
|
if (!File.Exists(path)) |
||||
|
{ |
||||
|
throw new FileNotFoundException(path + "路径下的文件未找到!"); |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(); |
||||
|
configFile.ExeConfigFilename = path; |
||||
|
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None); |
||||
|
return config; |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,213 @@ |
|||||
|
using Quartz; |
||||
|
using Quartz.Xml.JobSchedulingData20; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Data; |
||||
|
using System.Data.Linq.Mapping; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Reflection; |
||||
|
using System.Runtime.Remoting.Messaging; |
||||
|
using System.Text; |
||||
|
using System.Text.RegularExpressions; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Web.UI; |
||||
|
using System.Xml.Linq; |
||||
|
using System.Xml.Serialization; |
||||
|
|
||||
|
namespace ICSSoft.FromERP |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 营业务税金及附加明细账
|
||||
|
/// </summary>
|
||||
|
public class YERP_005 : 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 async void Execute() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
Configuration config = GetConfig(); |
||||
|
//string url = config.ConnectionStrings.ConnectionStrings["APIAddStdWorkHour"].ConnectionString.ToString();
|
||||
|
|
||||
|
var Dates = DateTime.Now; |
||||
|
//log.Info("获取创建定额工时接口 " + url);
|
||||
|
//if (string.IsNullOrEmpty(url))
|
||||
|
//{
|
||||
|
// return;
|
||||
|
//}
|
||||
|
string conStr = ICSHelper.GetConnectString(); |
||||
|
//PdfDocument doc = new PdfDocument();
|
||||
|
//doc.LoadFromFile(@"C:\Users\andyxin\Desktop\日常文档\TS3400series_5200.pdf");//选择Microsoft XPS Document Writer打印机
|
||||
|
//doc.PrintSettings.PrinterName = "Canon TS3400 series";//打印PDF文档到XPS格式
|
||||
|
////doc.PrintSettings.PrintToFile(filename + ".pdf");
|
||||
|
//doc.Print();
|
||||
|
////log.Info("打印成功: " + path);
|
||||
|
|
||||
|
//Dictionary<string, string> dParam = new Dictionary<string, string>();
|
||||
|
//dParam.Add("RCARD", "123456");
|
||||
|
//dParam.Add("INVSTD", "654321");
|
||||
|
//dParam.Add("DEFINE", "测试OK");
|
||||
|
//BTPrint(@"D:\汇川27x7mm2排1.btw", "Microsoft Print to PDF", dParam);
|
||||
|
|
||||
|
//string aa = " < soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns: yerp = \"http://skch.com/YERP_005_TAX_VAT\" > " + @"
|
||||
|
// < soapenv:Header />
|
||||
|
// < soapenv:Body >
|
||||
|
// < yerp:YERP_005_OA1_MT >
|
||||
|
// < !--1 or more repetitions: -->
|
||||
|
// < TAX_SURTAX >
|
||||
|
// < SBJ_CD > 1 </ SBJ_CD >
|
||||
|
// < SBJ_NM > 1 </ SBJ_NM >
|
||||
|
// < YYYY >?</ YYYY >
|
||||
|
// < MM >?</ MM >
|
||||
|
// < DD >?</ DD >
|
||||
|
// < SPTDOC >?</ SPTDOC >
|
||||
|
// < SMR >?</ SMR >
|
||||
|
// < ODR_ACC >?</ ODR_ACC >
|
||||
|
// < !--Optional : -->
|
||||
|
// < DBTO_AMT >?</ DBTO_AMT >
|
||||
|
// < !--Optional : -->
|
||||
|
// < CRDTO_AMT >?</ CRDTO_AMT >
|
||||
|
// < !--Optional : -->
|
||||
|
// < DBTO_CRDTO_DVSN ></ DBTO_CRDTO_DVSN >
|
||||
|
// < !--Optional : -->
|
||||
|
// < BLNC >?</ BLNC >
|
||||
|
// </ TAX_SURTAX >
|
||||
|
// </ yerp : YERP_005_OA1_MT >
|
||||
|
// </ soapenv : Body >
|
||||
|
// </ soapenv : Envelope >";
|
||||
|
//< soapenv:Envelope xmlns:soapenv = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: yerp = "http://skch.com/YERP_005_TAX_VAT" >
|
||||
|
// < soapenv:Header />
|
||||
|
// < soapenv:Body >
|
||||
|
// < yerp:YERP_005_OA1_MT >
|
||||
|
// < !--1 or more repetitions: -->
|
||||
|
// < TAX_SURTAX >
|
||||
|
// < SBJ_CD > 6403 </ SBJ_CD >
|
||||
|
// < SBJ_NM > 营业税金及附加 </ SBJ_NM >
|
||||
|
// < !--Optional : -->
|
||||
|
// < YYYY > 2024 </ YYYY >
|
||||
|
// < !--Optional : -->
|
||||
|
// < MM > 7 </ MM >
|
||||
|
// < !--Optional : -->
|
||||
|
// < SMR > 期初余额 </ SMR >
|
||||
|
// < !--Optional : -->
|
||||
|
// < DBTO_CRDTO_DVSN > 平 </ DBTO_CRDTO_DVSN >
|
||||
|
// < !--Optional : -->
|
||||
|
// < BLNC > 0.00000000 </ BLNC >
|
||||
|
// </ TAX_SURTAX >
|
||||
|
// </ yerp : YERP_005_OA1_MT >
|
||||
|
// </ soapenv : Body >
|
||||
|
// </ soapenv : Envelope >
|
||||
|
// 202404
|
||||
|
// 过滤时间为上个月
|
||||
|
string Date = Dates.ToString("yyyy"); |
||||
|
string Muoth = Dates.AddMonths(-1).ToString("MM"); |
||||
|
string Day = Dates.ToString("dd"); |
||||
|
var beginPeriod = "200001";//Date + Muoth;
|
||||
|
var endPeriod = "209001";//Date + Muoth;
|
||||
|
string sqls = @"begin transaction
|
||||
|
exec GL_Ledger @tblname=N'yysjmxz',@KmCode=N'6403',@beginPeriod={0},@endPeriod={1},@bVouch=0,@bequal=1,@sum=0,@bMJ=1,@swhere=N'',@sAuth=N'',@ReportID=N'GL13',@ReportType=0,@iUnite=0 |
||||
|
|
||||
|
select autoid,cCode SBJ_CD,ccode_name SBJ_NM,iyear YYYY,imonth MM,iday DD,csign_no SPTDOC,cDigest SMR,cDCode ODR_ACC,md DBTO_AMT,mc CRDTO_AMT,(case when ibook is null then '平' else (case when ibook ='1' then '贷' else '借' end) end) DBTO_CRDTO_DVSN,tmpme, |
||||
|
(Select Sum(tmpme) from tempdb..yysjmxz where autoid<=a.autoid) BLNC from tempdb..yysjmxz a |
||||
|
|
||||
|
|
||||
|
rollback transaction";
|
||||
|
sqls = string.Format(sqls, beginPeriod, endPeriod); |
||||
|
log.Info("YERP_005 sql:" + sqls); |
||||
|
DataTable vbsdt = ICSHelper.ExecuteTable(conStr, sqls); |
||||
|
log.Info("sql结果数量"+vbsdt.Rows.Count); |
||||
|
if (vbsdt.Rows.Count > 0) |
||||
|
{ |
||||
|
StringBuilder soapRequestData = new StringBuilder(); |
||||
|
soapRequestData.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:yerp=\"http://skch.com/YERP_005_TAX_VAT\">"); |
||||
|
soapRequestData.Append("<soapenv:Header/>"); |
||||
|
soapRequestData.Append("<soapenv:Body>"); |
||||
|
soapRequestData.Append("<yerp:YERP_005_OA1_MT>"); |
||||
|
//循环数据
|
||||
|
foreach (DataRow itemRow in vbsdt.Rows) |
||||
|
{ |
||||
|
//原循环部分 begin
|
||||
|
soapRequestData.Append("<TAX_SURTAX>"); |
||||
|
soapRequestData.Append(itemRow["SBJ_CD"] != null ? "<SBJ_CD>" + itemRow["SBJ_CD"].ToString() + "</SBJ_CD>" : "<SBJ_CD>" + "</SBJ_CD>"); |
||||
|
soapRequestData.Append(itemRow["SBJ_NM"] != null ? "<SBJ_NM>" + itemRow["SBJ_NM"].ToString() + "</SBJ_NM>" : "<SBJ_NM>" + "</SBJ_NM>"); |
||||
|
soapRequestData.Append(itemRow["YYYY"] != null ? "<YYYY>" + itemRow["YYYY"].ToString() + "</YYYY>" : "<YYYY>" + "</YYYY>"); |
||||
|
soapRequestData.Append(itemRow["MM"] != null ? "<MM>" + itemRow["MM"].ToString() + "</MM>" : "<MM>" + "</MM>"); |
||||
|
soapRequestData.Append(itemRow["DD"] != null ? "<DD>" + itemRow["DD"].ToString() + "</DD>" : "<DD>" + "</DD>"); |
||||
|
soapRequestData.Append(itemRow["SPTDOC"] != null ? "<SPTDOC>" + itemRow["SPTDOC"].ToString() + "</SPTDOC>" : "<SPTDOC>" + "</SPTDOC>"); |
||||
|
soapRequestData.Append(itemRow["SMR"] != null ? "<SMR>" + itemRow["SMR"].ToString() + "</SMR>" : "<SMR>" + "</SMR>"); |
||||
|
soapRequestData.Append(itemRow["ODR_ACC"] != null ? "<ODR_ACC>" + itemRow["ODR_ACC"].ToString() + "</ODR_ACC>" : "<ODR_ACC>" + "</ODR_ACC>"); |
||||
|
soapRequestData.Append(itemRow["DBTO_AMT"] != null ? "<DBTO_AMT>" + itemRow["DBTO_AMT"].ToString() + "</DBTO_AMT>" : "<DBTO_AMT>" + "</DBTO_AMT>"); |
||||
|
soapRequestData.Append(itemRow["CRDTO_AMT"] != null ? "<CRDTO_AMT>" + itemRow["CRDTO_AMT"].ToString() + "</CRDTO_AMT>" : "<CRDTO_AMT>" + "</CRDTO_AMT>"); |
||||
|
soapRequestData.Append(itemRow["DBTO_CRDTO_DVSN"] != null ? "<DBTO_CRDTO_DVSN>" + itemRow["DBTO_CRDTO_DVSN"].ToString() + "</DBTO_CRDTO_DVSN>" : "<DBTO_CRDTO_DVSN>" + "</DBTO_CRDTO_DVSN>"); |
||||
|
soapRequestData.Append(itemRow["BLNC"] != null ? "<BLNC>" + itemRow["BLNC"].ToString() + "</BLNC>" : "<BLNC>" + "</BLNC>"); |
||||
|
soapRequestData.Append("</TAX_SURTAX>"); |
||||
|
//原循环部分 end
|
||||
|
} |
||||
|
soapRequestData.Append("</yerp:YERP_005_OA1_MT>"); |
||||
|
soapRequestData.Append("</soapenv:Body>"); |
||||
|
soapRequestData.Append("</soapenv:Envelope>"); |
||||
|
string postData = soapRequestData.ToString(); |
||||
|
log.Info("YERP_005 xmlRequest:" + postData); |
||||
|
|
||||
|
string statusCode; |
||||
|
string resultContent; |
||||
|
|
||||
|
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072; |
||||
|
RestOpHelper rop = new RestOpHelper(); |
||||
|
rop.Clientp12path = @"C:\Users\Administrator\Desktop\yonyou-cert\wildcard.pfx"; |
||||
|
rop.Clientp12PassWord = "Yonyou2024!"; |
||||
|
rop.Url = @"https://yerp-proxy-sap-dev.skchemicals.com/XISOAPAdapter/MessageServlet?senderParty=&senderService=YERP_D&receiverParty=&receiverService=&interface=YERP_005_OA1_SI&interfaceNamespace=http://skch.com/YERP_005_TAX_VAT"; |
||||
|
rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); |
||||
|
|
||||
|
log.Info("YERP_005 statusCode:" + statusCode + "\r\n" + "resultContent:" + resultContent); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
log.Error(ex.ToString()); |
||||
|
} |
||||
|
} |
||||
|
public static Configuration GetConfig() |
||||
|
{ |
||||
|
Assembly assembly = Assembly.GetCallingAssembly(); |
||||
|
string path = string.Format("{0}.config", assembly.Location); |
||||
|
if (!File.Exists(path)) |
||||
|
{ |
||||
|
throw new FileNotFoundException(path + "路径下的文件未找到!"); |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(); |
||||
|
configFile.ExeConfigFilename = path; |
||||
|
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None); |
||||
|
return config; |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,244 @@ |
|||||
|
using Quartz; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Data; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Reflection; |
||||
|
using System.Text; |
||||
|
using System.Text.RegularExpressions; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace ICSSoft.FromERP |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 财务费用 明细账
|
||||
|
/// </summary>
|
||||
|
public class YERP_007 : 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 async void Execute() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
Configuration config = GetConfig(); |
||||
|
|
||||
|
var Dates = DateTime.Now; |
||||
|
string conStr = ICSHelper.GetConnectString(); |
||||
|
//<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:yerp="http://skch.com/YERP_007_TAX_FOR_FIN_EXPENSE">
|
||||
|
// <soapenv:Header/>
|
||||
|
// <soapenv:Body>
|
||||
|
// <yerp:YERP_007_OA1_MT>
|
||||
|
// <!--1 or more repetitions:-->
|
||||
|
// <FIN_CST_SPTDOC>
|
||||
|
// <YYYY>?</YYYY>
|
||||
|
// <MM>1</MM>
|
||||
|
// <DD>?</DD>
|
||||
|
// <SPTDOC>?</SPTDOC>
|
||||
|
// <SMR>?</SMR>
|
||||
|
// <DBTO>?</DBTO>
|
||||
|
// <CRDTO>?</CRDTO>
|
||||
|
// <DBTO_CRDTO_DVSN>?</DBTO_CRDTO_DVSN>
|
||||
|
// <BLNC>?</BLNC>
|
||||
|
// <!--Optional:-->
|
||||
|
// <DBTO_CMSN>?</DBTO_CMSN>
|
||||
|
// <!--Optional:-->
|
||||
|
// <DBTO_IENS>?</DBTO_IENS>
|
||||
|
// <!--Optional:-->
|
||||
|
// <DBTO_XCH_PC>?</DBTO_XCH_PC>
|
||||
|
// </FIN_CST_SPTDOC>
|
||||
|
// </yerp:YERP_007_OA1_MT>
|
||||
|
// </soapenv:Body>
|
||||
|
//</soapenv:Envelope>
|
||||
|
|
||||
|
// 过滤时间为上个月
|
||||
|
var beginPeriod = "2023-06-01";// Dates.AddMonths(-1).AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-06-01";
|
||||
|
var endPeriod = "2023-07-01";// Dates.AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-07-01";
|
||||
|
string sqls = @"
|
||||
|
begin transaction |
||||
|
|
||||
|
exec GL_Ledger @tblname=N'cwfymxz',@KmCode=N'6603',@beginPeriod=202404,@endPeriod=202406,@bVouch=0,@bequal=1,@sum=0,@bMJ=1,@swhere=N'',@sAuth=N'',@ReportID=N'GL13',@ReportType=0,@iUnite=0 |
||||
|
|
||||
|
--select * from tempdb..cwfymxz |
||||
|
|
||||
|
|
||||
|
select autoid,iyear YYYY,imonth MM,iday DD,csign_no SPTDOC,cDigest SMR,cDCode ODR_ACC,md DBTO_AMT,mc CRDTO_AMT,tmpme tmpme |
||||
|
into #test |
||||
|
from tempdb..cwfymxz a |
||||
|
|
||||
|
select SPTDOC,YYYY,MM,DD,sum(DBTO_AMT) DBTO_AMT,sum(CRDTO_AMT) CRDTO_AMT,sum(isnull(tmpme,0)) tmpme |
||||
|
into #test2 |
||||
|
from #test a |
||||
|
where SPTDOC is not null and DD IS NOT NULL |
||||
|
group by SPTDOC,YYYY,MM,DD |
||||
|
order by SPTDOC |
||||
|
|
||||
|
update a set DBTO_AMT=b.DBTO_AMT,a.CRDTO_AMT=b.CRDTO_AMT,a.tmpme=b.tmpme from #test a |
||||
|
left join #test2 b on a.SPTDOC=b.SPTDOC and a.MM=b.MM and a.DD=b.DD |
||||
|
where a.sptdoc is not null |
||||
|
|
||||
|
select autoid,sptdoc,YYYY,MM,DD into #test3 from #test where sptdoc is not null |
||||
|
|
||||
|
select s.* into #test4 from (select *,ROW_NUMBER() over (partition by sptdoc+CAST(MM AS VARCHAR(255))+CAST(DD AS VARCHAR(255)) order by autoid) as group_idx from #test3)s where s.group_idx>1 |
||||
|
|
||||
|
delete a from #test a |
||||
|
left join #test4 b on a.autoid=b.autoid |
||||
|
where b.autoid is not null |
||||
|
|
||||
|
select *,(case when (Select Sum(-tmpme) from #test where autoid<=a.autoid) =0 then '平' else (case when (Select Sum(-tmpme) from #test where autoid<=a.autoid) >0 then '贷' else '借' end) end) INVT, |
||||
|
(case when (Select Sum(-tmpme) from #test where autoid<=a.autoid)<0 then -(Select Sum(-tmpme) from #test where autoid<=a.autoid) else (Select Sum(-tmpme) from #test where autoid<=a.autoid) end) BLNC |
||||
|
into #test5 |
||||
|
from #test a |
||||
|
|
||||
|
select cCode SBJ_CD,ccode_name SBJ_NM,imonth,iday,csign_no SPTDOC,sum(md) DBTO_AMT |
||||
|
into #test6 |
||||
|
from tempdb..cwfymxz a |
||||
|
where csign_no is not null |
||||
|
group by ccode_name,csign_no,cCode,imonth,iday |
||||
|
order by csign_no,imonth,iday |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
select DISTINCT sptdoc,imonth,iday into #test7 from #test6 |
||||
|
select *,ROW_NUMBER() over (order by sptdoc,imonth,iday) rownumber into #test8 from #test7 |
||||
|
|
||||
|
|
||||
|
declare @k int |
||||
|
set @k=1 |
||||
|
while @k<=(select COUNT(*) from #test7) |
||||
|
begin |
||||
|
declare @i int |
||||
|
set @i=0 |
||||
|
while @i<1 |
||||
|
begin |
||||
|
|
||||
|
insert into #test6 (SBJ_CD,SBJ_NM,imonth,iday,SPTDOC,DBTO_AMT) |
||||
|
select a.ccode,a.ccode_name,(select imonth from #test8 where rownumber=@k),(select iday from #test8 where rownumber=@k),(select SPTDOC from #test8 where rownumber=@k),0 |
||||
|
from code a left join #test6 b on b.SPTDOC=(select SPTDOC from #test8 where rownumber=@k) and imonth=(select imonth from #test8 where rownumber=@k) and iday=(select iday from #test8 where rownumber=@k) and SBJ_NM=ccode_name |
||||
|
where a.iYear=2024 and ( bclose=0 and ( ccode like N'6603%' or ccode_name like N'6603%' or ccode_engl like N'6603%' or chelp like N'6603%' )) and ccode <>'6603' and len(ccode)=6 |
||||
|
and b.SPTDOC is null |
||||
|
set @i=@i +1 |
||||
|
end |
||||
|
|
||||
|
|
||||
|
set @k=@k +1 |
||||
|
end |
||||
|
|
||||
|
|
||||
|
SELECT |
||||
|
SPTDOC,imonth,iday, |
||||
|
SUM(CASE WHEN SBJ_CD = '660301' THEN DBTO_AMT ELSE 0 END) DBTO_CMSN, |
||||
|
SUM(CASE WHEN SBJ_CD = '660302' THEN DBTO_AMT ELSE 0 END) DBTO_IENS, |
||||
|
SUM(CASE WHEN SBJ_CD = '660303' THEN DBTO_AMT ELSE 0 END) DBTO_XCH_PC |
||||
|
|
||||
|
into #test9 |
||||
|
FROM |
||||
|
#test6 |
||||
|
GROUP BY |
||||
|
SPTDOC,imonth,iday |
||||
|
|
||||
|
|
||||
|
select YYYY,MM,DD,A.SPTDOC,SMR,DBTO_AMT DBTO,CRDTO_AMT CRDTO,INVT,BLNC,DBTO_CMSN,DBTO_IENS,DBTO_XCH_PC |
||||
|
|
||||
|
from #test5 a left join #test9 b on a.SPTDOC=b.SPTDOC and a.MM=b.imonth and a.DD=b.iday order by MM |
||||
|
|
||||
|
rollback transaction";//and dInvCreateDatetime > '{0}' and dInvCreateDatetime < '{1}'
|
||||
|
|
||||
|
sqls = string.Format(sqls, beginPeriod, endPeriod); |
||||
|
log.Info("YERP_007 sql:" + sqls); |
||||
|
DataTable vbsdt = ICSHelper.ExecuteTable(conStr, sqls); |
||||
|
log.Info("YERP_007 sql结果数量" + vbsdt.Rows.Count); |
||||
|
if (vbsdt.Rows.Count > 0) |
||||
|
{ |
||||
|
StringBuilder soapRequestData = new StringBuilder(); |
||||
|
soapRequestData.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:yerp=\"http://skch.com/YERP_007_TAX_FOR_FIN_EXPENSE\">"); |
||||
|
soapRequestData.Append("<soapenv:Header/>"); |
||||
|
soapRequestData.Append("<soapenv:Body>"); |
||||
|
soapRequestData.Append("<yerp:YERP_007_OA1_MT>"); |
||||
|
//循环数据 DBTO_CRDTO_DVSN
|
||||
|
foreach (DataRow itemRow in vbsdt.Rows) |
||||
|
{ |
||||
|
soapRequestData.Append("<!--Zero or more repetitions: -->"); |
||||
|
soapRequestData.Append("<FIN_CST_SPTDOC>"); |
||||
|
soapRequestData.Append(itemRow["YYYY"] != null ? "<YYYY>" + itemRow["YYYY"].ToString() + "</YYYY>" : "<YYYY>" + "</YYYY>"); |
||||
|
soapRequestData.Append(itemRow["MM"] != null ? "<MM>" + itemRow["MM"].ToString() + "</MM>" : "<MM>" + "</MM>"); |
||||
|
soapRequestData.Append(itemRow["DD"] != null ? "<DD>" + itemRow["DD"].ToString() + "</DD>" : "<DD>" + "</DD>"); |
||||
|
soapRequestData.Append(itemRow["SPTDOC"] != null ? "<SPTDOC>" + itemRow["SPTDOC"].ToString() + "</SPTDOC>" : "<SPTDOC>" + "</SPTDOC>"); |
||||
|
soapRequestData.Append(itemRow["SMR"] != null ? "<SMR>" + itemRow["SMR"].ToString() + "</SMR>" : "<SMR>" + "</SMR>"); |
||||
|
soapRequestData.Append(itemRow["DBTO"] != null ? "<DBTO>" + itemRow["DBTO"].ToString() + "</DBTO>" : "<DBTO>" + "</DBTO>"); |
||||
|
soapRequestData.Append(itemRow["CRDTO"] != null ? "<CRDTO>" + itemRow["CRDTO"].ToString() + "</CRDTO>" : "<CRDTO>" + "</CRDTO>"); |
||||
|
soapRequestData.Append(itemRow["DBTO_CRDTO_DVSN"] != null ? "<DBTO_CRDTO_DVSN>" + itemRow["DBTO_CRDTO_DVSN"].ToString() + "</DBTO_CRDTO_DVSN>" : "<DBTO_CRDTO_DVSN>" + "</DBTO_CRDTO_DVSN>"); |
||||
|
soapRequestData.Append(itemRow["BLNC"] != null ? "<BLNC>" + itemRow["BLNC"].ToString() + "</BLNC>" : "<BLNC>" + "</BLNC>"); |
||||
|
soapRequestData.Append(itemRow["DBTO_CMSN"] != null ? "<DBTO_CMSN>" + itemRow["DBTO_CMSN"].ToString() + "</DBTO_CMSN>" : "<DBTO_CMSN>" + "</DBTO_CMSN>"); |
||||
|
soapRequestData.Append(itemRow["DBTO_IENS"] != null ? "<DBTO_IENS>" + itemRow["DBTO_IENS"].ToString() + "</DBTO_IENS>" : "<DBTO_IENS>" + "</DBTO_IENS>"); |
||||
|
soapRequestData.Append(itemRow["DBTO_XCH_PC"] != null ? "<DBTO_XCH_PC>" + itemRow["DBTO_XCH_PC"].ToString() + "</DBTO_XCH_PC>" : "<DBTO_XCH_PC>" + "</DBTO_XCH_PC>"); |
||||
|
soapRequestData.Append("</FIN_CST_SPTDOC>"); |
||||
|
} |
||||
|
|
||||
|
soapRequestData.Append("</yerp:YERP_007_OA1_MT>"); |
||||
|
soapRequestData.Append("</soapenv:Body>"); |
||||
|
soapRequestData.Append("</soapenv:Envelope>"); |
||||
|
string postData = soapRequestData.ToString(); |
||||
|
log.Info("YERP_007 xmlRequest:" + postData); |
||||
|
|
||||
|
string statusCode; |
||||
|
string resultContent; |
||||
|
|
||||
|
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072; |
||||
|
RestOpHelper rop = new RestOpHelper(); |
||||
|
rop.Clientp12path = @"C:\Users\Administrator\Desktop\yonyou-cert\wildcard.pfx"; |
||||
|
rop.Clientp12PassWord = "Yonyou2024!"; |
||||
|
rop.Url = @"https://yerp-proxy-sap-dev.skchemicals.com/XISOAPAdapter/MessageServlet?senderParty=&senderService=YERP_D&receiverParty=&receiverService=&interface=YERP_007_OA1_SI&interfaceNamespace=http://skch.com/YERP_007_TAX_FOR_FIN_EXPENSE"; |
||||
|
rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); |
||||
|
|
||||
|
log.Info("YERP_007 statusCode:" + statusCode + "\r\n" + "resultContent:" + resultContent); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
log.Error(ex.ToString()); |
||||
|
} |
||||
|
} |
||||
|
public static Configuration GetConfig() |
||||
|
{ |
||||
|
Assembly assembly = Assembly.GetCallingAssembly(); |
||||
|
string path = string.Format("{0}.config", assembly.Location); |
||||
|
if (!File.Exists(path)) |
||||
|
{ |
||||
|
throw new FileNotFoundException(path + "路径下的文件未找到!"); |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(); |
||||
|
configFile.ExeConfigFilename = path; |
||||
|
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None); |
||||
|
return config; |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,169 @@ |
|||||
|
using Quartz; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Data; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Reflection; |
||||
|
using System.Runtime.Remoting.Messaging; |
||||
|
using System.Text; |
||||
|
using System.Text.RegularExpressions; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace ICSSoft.FromERP |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Item Master(物料主数据)
|
||||
|
/// </summary>
|
||||
|
public class YERP_008 : 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 async void Execute() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
Configuration config = GetConfig(); |
||||
|
|
||||
|
var Dates = DateTime.Now; |
||||
|
string conStr = ICSHelper.GetConnectString(); |
||||
|
//<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:yerp="http://skch.com/YERP_008_ITEM_INFO">
|
||||
|
// <soapenv:Header/>
|
||||
|
// <soapenv:Body>
|
||||
|
// <yerp:YERP_008_OA1_MT>
|
||||
|
// <!--Zero or more repetitions: -->
|
||||
|
// <IF_ITEM_MST>
|
||||
|
// <IF_STD_DATE>20240814</IF_STD_DATE>
|
||||
|
// <ITEM_CD>201010</ITEM_CD>
|
||||
|
// <ITEM_NM>ECOTRION H1000</ITEM_NM>
|
||||
|
// <!--Optional:-->
|
||||
|
// <ITEM_PACK_UOM>kg</ITEM_PACK_UOM>
|
||||
|
// <!--Optional:-->
|
||||
|
// <CREATE_DTTM>20230713</CREATE_DTTM>
|
||||
|
// <!--Optional:-->
|
||||
|
// <CREATE_BY>21436</CREATE_BY>
|
||||
|
// <!--Optional:-->
|
||||
|
// <ROW_CNT>1</ROW_CNT>
|
||||
|
// </IF_ITEM_MST>
|
||||
|
// </yerp:YERP_008_OA1_MT>
|
||||
|
// </soapenv:Body>
|
||||
|
// </soapenv:Envelope>
|
||||
|
// 过滤时间为上个月
|
||||
|
var beginPeriod = "2023-06-01";// Dates.AddMonths(-1).AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-06-01";
|
||||
|
var endPeriod = "2023-07-01";// Dates.AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-07-01";
|
||||
|
string sqls = @"select convert(nvarchar(10),getdate(),112) IF_STD_DATE,
|
||||
|
cInvCode ITEM_CD, |
||||
|
d.cInvCName+' '+cInvName ITEM_NM, |
||||
|
a.cInvCCode BRND_CD, |
||||
|
'' GRADE_CD, |
||||
|
d.cInvCName BRND_NM, |
||||
|
cInvName GRADE_NM, |
||||
|
cInvStd ITEM_PACK_UOM, |
||||
|
(case when cInvStd is null then '0' else (CASE WHEN ISNUMERIC(left(cinvstd,3)) = 1 THEN left(cinvstd,3) ELSE (CASE WHEN ISNUMERIC(left(cinvstd,2)) = 1 |
||||
|
THEN left(cinvstd,2) ELSE (CASE WHEN ISNUMERIC(left(cinvstd,1)) = 1 THEN left(cinvstd,1) ELSE 0 END) END) END) end) PACK_MIN_QTY, |
||||
|
dInvCreateDatetime CREATE_DTTM, |
||||
|
cCreatePerson CREATE_BY, |
||||
|
dModifyDate MODIFY_DTTM, |
||||
|
cModifyPerson MODIFY_BY, |
||||
|
COUNT(*) OVER (PARTITION BY getdate()) ROW_CNT |
||||
|
from dbo.Inventory a |
||||
|
left join dbo.Inventory_Sub b on a.cInvCode=b.cInvSubCode |
||||
|
left join dbo.ComputationUnit c on a.cComUnitCode=c.cComunitCode |
||||
|
left join dbo.InventoryClass d on a.cInvCCode=d.cInvCCode |
||||
|
WHERE 1 = 1 ";//and dInvCreateDatetime > '{0}' and dInvCreateDatetime < '{1}'
|
||||
|
|
||||
|
sqls = string.Format(sqls, beginPeriod, endPeriod); |
||||
|
log.Info("YERP_008 sql:"+sqls); |
||||
|
DataTable vbsdt = ICSHelper.ExecuteTable(conStr, sqls); |
||||
|
log.Info("YERP_008 sql结果数量" + vbsdt.Rows.Count); |
||||
|
if (vbsdt.Rows.Count > 0) |
||||
|
{ |
||||
|
StringBuilder soapRequestData = new StringBuilder(); |
||||
|
soapRequestData.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:yerp=\"http://skch.com/YERP_008_ITEM_INFO\">"); |
||||
|
soapRequestData.Append("<soapenv:Header/>"); |
||||
|
soapRequestData.Append("<soapenv:Body>"); |
||||
|
soapRequestData.Append("<yerp:YERP_008_OA1_MT>"); |
||||
|
//循环数据
|
||||
|
foreach (DataRow itemRow in vbsdt.Rows) |
||||
|
{ |
||||
|
soapRequestData.Append("<!--Zero or more repetitions: -->"); |
||||
|
soapRequestData.Append("<IF_ITEM_MST>"); |
||||
|
soapRequestData.Append(itemRow["IF_STD_DATE"] != null ? "<IF_STD_DATE>" + itemRow["IF_STD_DATE"].ToString() + "</IF_STD_DATE>" : "<IF_STD_DATE>" + "</IF_STD_DATE>"); |
||||
|
soapRequestData.Append(itemRow["ITEM_CD"] != null ? "<ITEM_CD>" + itemRow["ITEM_CD"].ToString() + "</ITEM_CD>" : "<ITEM_CD>" + "</ITEM_CD>"); |
||||
|
soapRequestData.Append(itemRow["ITEM_NM"] != null ? "<ITEM_NM>" + itemRow["ITEM_NM"].ToString() + "</ITEM_NM>" : "<ITEM_NM>" + "</ITEM_NM>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["ITEM_PACK_UOM"] != null ? "<ITEM_PACK_UOM>" + Regex.Replace(itemRow["ITEM_PACK_UOM"].ToString(), @"[^0-9]+", "") + "</ITEM_PACK_UOM>" : "<ITEM_PACK_UOM>" + "</ITEM_PACK_UOM>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["CREATE_DTTM"] != null ? "<CREATE_DTTM>" + itemRow["CREATE_DTTM"].ToString() + "</CREATE_DTTM>" : "<CREATE_DTTM>" + "</CREATE_DTTM>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["CREATE_BY"] != null ? "<CREATE_BY>" + itemRow["CREATE_BY"].ToString() + "</CREATE_BY>" : "<CREATE_BY>" + "</CREATE_BY>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["ROW_CNT"] != null ? "<ROW_CNT>" + itemRow["ROW_CNT"].ToString() + "</ROW_CNT>" : "<ROW_CNT>" + "</ROW_CNT>"); |
||||
|
soapRequestData.Append("</IF_ITEM_MST>"); |
||||
|
} |
||||
|
|
||||
|
soapRequestData.Append("</yerp:YERP_008_OA1_MT>"); |
||||
|
soapRequestData.Append("</soapenv:Body>"); |
||||
|
soapRequestData.Append("</soapenv:Envelope>"); |
||||
|
string postData = soapRequestData.ToString(); |
||||
|
log.Info("YERP_008 xmlRequest:" + postData); |
||||
|
|
||||
|
string statusCode; |
||||
|
string resultContent; |
||||
|
|
||||
|
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072; |
||||
|
RestOpHelper rop = new RestOpHelper(); |
||||
|
rop.Clientp12path = @"C:\Users\Administrator\Desktop\yonyou-cert\wildcard.pfx"; |
||||
|
rop.Clientp12PassWord = "Yonyou2024!"; |
||||
|
rop.Url = @"https://yerp-proxy-sap-dev.skchemicals.com/XISOAPAdapter/MessageServlet?senderParty=&senderService=YERP_D&receiverParty=&receiverService=&interface=YERP_008_OA1_SI&interfaceNamespace=http://skch.com/YERP_008_ITEM_INFO"; |
||||
|
rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); |
||||
|
|
||||
|
log.Info("YERP_008 statusCode:" + statusCode + "\r\n" + "resultContent:" + resultContent); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
log.Error(ex.ToString()); |
||||
|
} |
||||
|
} |
||||
|
public static Configuration GetConfig() |
||||
|
{ |
||||
|
Assembly assembly = Assembly.GetCallingAssembly(); |
||||
|
string path = string.Format("{0}.config", assembly.Location); |
||||
|
if (!File.Exists(path)) |
||||
|
{ |
||||
|
throw new FileNotFoundException(path + "路径下的文件未找到!"); |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(); |
||||
|
configFile.ExeConfigFilename = path; |
||||
|
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None); |
||||
|
return config; |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,177 @@ |
|||||
|
using Quartz; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Data; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Reflection; |
||||
|
using System.Text; |
||||
|
using System.Text.RegularExpressions; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace ICSSoft.FromERP |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Stock information 库存信息 日
|
||||
|
/// </summary>
|
||||
|
public class YERP_010_BOH : 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 async void Execute() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
Configuration config = GetConfig(); |
||||
|
|
||||
|
var Dates = DateTime.Now; |
||||
|
string conStr = ICSHelper.GetConnectString(); |
||||
|
//<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:yerp="http://skch.com/YERP_010_IF_STCK_HST">
|
||||
|
// <soapenv:Header/>
|
||||
|
// <soapenv:Body>
|
||||
|
// <yerp:YERP_010_OA1_MT>
|
||||
|
// <!--Zero or more repetitions:-->
|
||||
|
// <IF_STCK_HST>
|
||||
|
// <IF_STD_DATE>2024-07-01</IF_STD_DATE>
|
||||
|
// <!--Optional:-->
|
||||
|
// <STCK_STD_DATE>2024-07-01</STCK_STD_DATE>
|
||||
|
// <!--Optional:-->
|
||||
|
// <WRHS_CD>?</WRHS_CD>
|
||||
|
// <ITEM_CD>?</ITEM_CD>
|
||||
|
// <!--Optional:-->
|
||||
|
// <PRDT_BTCH_NO>?</PRDT_BTCH_NO>
|
||||
|
// <STCK_TYPE_CD>?</STCK_TYPE_CD>
|
||||
|
// <!--Optional:-->
|
||||
|
// <STCK_QTY>?</STCK_QTY>
|
||||
|
// <!--Optional:-->
|
||||
|
// <STCK_VALUE_CNW>?</STCK_VALUE_CNW>
|
||||
|
// <!--Optional:-->
|
||||
|
// <STCK_UOM>?</STCK_UOM>
|
||||
|
// <!--Optional:-->
|
||||
|
// <PACK_MIN_QTY>?</PACK_MIN_QTY>
|
||||
|
// <GEN_ROW_CNT>?</GEN_ROW_CNT>
|
||||
|
// </IF_STCK_HST>
|
||||
|
// </yerp:YERP_010_OA1_MT>
|
||||
|
// </soapenv:Body>
|
||||
|
//</soapenv:Envelope>
|
||||
|
|
||||
|
// 过滤按天数
|
||||
|
var beginPeriod = "2023-06-01";// Dates.AddMonths(-1).AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-06-01";
|
||||
|
var endPeriod = "2023-07-01";// Dates.AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-07-01";
|
||||
|
string sqls = @"
|
||||
|
|
||||
|
select convert(nvarchar(10),getdate(),112) IF_STD_DATE, |
||||
|
convert(nvarchar(10),getdate(),112) STCK_STD_DATE, |
||||
|
cWhCode WRHS_CD, |
||||
|
a.cInvCode ITEM_CD, |
||||
|
cBatch PRDT_BTCH_NO, |
||||
|
'BOH' STCK_TYPE_CD, |
||||
|
iQuantity STCK_QTY, |
||||
|
0 STCK_VALUE_CNW, |
||||
|
'' STCK_VALUE_UOM, |
||||
|
(case when cInvStd is null then null else (CASE WHEN ISNUMERIC(left(cinvstd,3)) = 1 THEN REPLACE(SUBSTRING(cinvstd, 1, CHARINDEX('/', cinvstd) - 1),left(cinvstd,3),'') ELSE (CASE WHEN ISNUMERIC(left(cinvstd,2)) = 1 |
||||
|
THEN REPLACE(SUBSTRING(cinvstd, 1, CHARINDEX('/', cinvstd) - 1),left(cinvstd,2),'') ELSE (CASE WHEN ISNUMERIC(left(cinvstd,1)) = 1 |
||||
|
THEN REPLACE(SUBSTRING(cinvstd, 1, CHARINDEX('/', cinvstd) - 1),left(cinvstd,1),'') ELSE '' END) END) END) end) STCK_UOM, |
||||
|
cInvStd PACK_MIN_QTY, |
||||
|
COUNT(*) OVER (PARTITION BY getdate()) GEN_ROW_CNT |
||||
|
from CurrentStock a |
||||
|
left join dbo.Inventory c on a.cInvCode=c.cInvCode |
||||
|
where 1 = 1 and iQuantity > 0";//and dInvCreateDatetime > '{0}' and dInvCreateDatetime < '{1}'
|
||||
|
|
||||
|
sqls = string.Format(sqls, beginPeriod, endPeriod); |
||||
|
log.Info("YERP_010 sql:" + sqls); |
||||
|
DataTable vbsdt = ICSHelper.ExecuteTable(conStr, sqls); |
||||
|
log.Info("YERP_010 sql结果数量" + vbsdt.Rows.Count); |
||||
|
if (vbsdt.Rows.Count > 0) |
||||
|
{ |
||||
|
StringBuilder soapRequestData = new StringBuilder(); |
||||
|
soapRequestData.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:yerp=\"http://skch.com/YERP_010_IF_STCK_HST\">"); |
||||
|
soapRequestData.Append("<soapenv:Header/>"); |
||||
|
soapRequestData.Append("<soapenv:Body>"); |
||||
|
soapRequestData.Append("<yerp:YERP_010_OA1_MT>"); |
||||
|
//循环数据 STCK_STD_DATE STCK_TYPE_CD STCK_VALUE_CNW
|
||||
|
foreach (DataRow itemRow in vbsdt.Rows) |
||||
|
{ |
||||
|
soapRequestData.Append("<!--Zero or more repetitions: -->"); |
||||
|
soapRequestData.Append("<IF_STCK_HST>"); |
||||
|
soapRequestData.Append(itemRow["IF_STD_DATE"] != null ? "<IF_STD_DATE>" + itemRow["IF_STD_DATE"].ToString() + "</IF_STD_DATE>" : "<IF_STD_DATE>" + "</IF_STD_DATE>"); |
||||
|
soapRequestData.Append(itemRow["STCK_STD_DATE"] != null ? "<STCK_STD_DATE>" + itemRow["STCK_STD_DATE"].ToString() + "</STCK_STD_DATE>" : "<STCK_STD_DATE>" + "</STCK_STD_DATE>"); |
||||
|
soapRequestData.Append(itemRow["WRHS_CD"] != null ? "<WRHS_CD>" + itemRow["WRHS_CD"].ToString() + "</WRHS_CD>" : "<WRHS_CD>" + "</WRHS_CD>"); |
||||
|
soapRequestData.Append(itemRow["ITEM_CD"] != null ? "<ITEM_CD>" + itemRow["ITEM_CD"].ToString() + "</ITEM_CD>" : "<ITEM_CD>" + "</ITEM_CD>"); |
||||
|
soapRequestData.Append(itemRow["PRDT_BTCH_NO"] != null ? "<PRDT_BTCH_NO>" + itemRow["PRDT_BTCH_NO"].ToString() + "</PRDT_BTCH_NO>" : "<PRDT_BTCH_NO>" + "</PRDT_BTCH_NO>"); |
||||
|
soapRequestData.Append(itemRow["STCK_TYPE_CD"] != null ? "<STCK_TYPE_CD>" + itemRow["STCK_TYPE_CD"].ToString() + "</STCK_TYPE_CD>" : "<STCK_TYPE_CD>" + "</STCK_TYPE_CD>"); |
||||
|
soapRequestData.Append(itemRow["STCK_QTY"] != null ? "<STCK_QTY>" + itemRow["STCK_QTY"].ToString() + "</STCK_QTY>" : "<STCK_QTY>" + "</STCK_QTY>"); |
||||
|
soapRequestData.Append(itemRow["STCK_VALUE_CNW"] != null ? "<STCK_VALUE_CNW>" + itemRow["STCK_VALUE_CNW"].ToString() + "</STCK_VALUE_CNW>" : "<STCK_VALUE_CNW>" + "</STCK_VALUE_CNW>"); |
||||
|
soapRequestData.Append(itemRow["STCK_UOM"] != null ? "<STCK_UOM>" + itemRow["STCK_UOM"].ToString() + "</STCK_UOM>" : "<STCK_UOM>" + "</STCK_UOM>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["PACK_MIN_QTY"] != null ? "<PACK_MIN_QTY>" + Regex.Replace(itemRow["PACK_MIN_QTY"].ToString(), @"[^0-9]+", "") + "</PACK_MIN_QTY>" : "<PACK_MIN_QTY>" + "</PACK_MIN_QTY>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["GEN_ROW_CNT"] != null ? "<GEN_ROW_CNT>" + itemRow["GEN_ROW_CNT"].ToString() + "</GEN_ROW_CNT>" : "<GEN_ROW_CNT>" + "</GEN_ROW_CNT>"); |
||||
|
soapRequestData.Append("</IF_STCK_HST>"); |
||||
|
} |
||||
|
|
||||
|
soapRequestData.Append("</yerp:YERP_010_OA1_MT>"); |
||||
|
soapRequestData.Append("</soapenv:Body>"); |
||||
|
soapRequestData.Append("</soapenv:Envelope>"); |
||||
|
string postData = soapRequestData.ToString(); |
||||
|
log.Info("YERP_010 xmlRequest:" + postData); |
||||
|
|
||||
|
string statusCode; |
||||
|
string resultContent; |
||||
|
|
||||
|
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072; |
||||
|
RestOpHelper rop = new RestOpHelper(); |
||||
|
rop.Clientp12path = @"C:\Users\Administrator\Desktop\yonyou-cert\wildcard.pfx"; |
||||
|
rop.Clientp12PassWord = "Yonyou2024!"; |
||||
|
rop.Url = @"https://yerp-proxy-sap-dev.skchemicals.com/XISOAPAdapter/MessageServlet?senderParty=&senderService=YERP_D&receiverParty=&receiverService=&interface=YERP_010_OA1_SI&interfaceNamespace=http://skch.com/YERP_010_IF_STCK_HST"; |
||||
|
rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); |
||||
|
|
||||
|
log.Info("YERP_010 statusCode:" + statusCode + "\r\n" + "resultContent:" + resultContent); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
log.Error(ex.ToString()); |
||||
|
} |
||||
|
} |
||||
|
public static Configuration GetConfig() |
||||
|
{ |
||||
|
Assembly assembly = Assembly.GetCallingAssembly(); |
||||
|
string path = string.Format("{0}.config", assembly.Location); |
||||
|
if (!File.Exists(path)) |
||||
|
{ |
||||
|
throw new FileNotFoundException(path + "路径下的文件未找到!"); |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(); |
||||
|
configFile.ExeConfigFilename = path; |
||||
|
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None); |
||||
|
return config; |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,178 @@ |
|||||
|
using Quartz; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Data; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Reflection; |
||||
|
using System.Text; |
||||
|
using System.Text.RegularExpressions; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace ICSSoft.FromERP |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Stock information 库存信息 月
|
||||
|
/// </summary>
|
||||
|
public class YERP_010_EOH : 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 async void Execute() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
Configuration config = GetConfig(); |
||||
|
|
||||
|
var Dates = DateTime.Now; |
||||
|
string conStr = ICSHelper.GetConnectString(); |
||||
|
//<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:yerp="http://skch.com/YERP_010_IF_STCK_HST">
|
||||
|
// <soapenv:Header/>
|
||||
|
// <soapenv:Body>
|
||||
|
// <yerp:YERP_010_OA1_MT>
|
||||
|
// <!--Zero or more repetitions:-->
|
||||
|
// <IF_STCK_HST>
|
||||
|
// <IF_STD_DATE>2024-07-01</IF_STD_DATE>
|
||||
|
// <!--Optional:-->
|
||||
|
// <STCK_STD_DATE>2024-07-01</STCK_STD_DATE>
|
||||
|
// <!--Optional:-->
|
||||
|
// <WRHS_CD>?</WRHS_CD>
|
||||
|
// <ITEM_CD>?</ITEM_CD>
|
||||
|
// <!--Optional:-->
|
||||
|
// <PRDT_BTCH_NO>?</PRDT_BTCH_NO>
|
||||
|
// <STCK_TYPE_CD>?</STCK_TYPE_CD>
|
||||
|
// <!--Optional:-->
|
||||
|
// <STCK_QTY>?</STCK_QTY>
|
||||
|
// <!--Optional:-->
|
||||
|
// <STCK_VALUE_CNW>?</STCK_VALUE_CNW>
|
||||
|
// <!--Optional:-->
|
||||
|
// <STCK_UOM>?</STCK_UOM>
|
||||
|
// <!--Optional:-->
|
||||
|
// <PACK_MIN_QTY>?</PACK_MIN_QTY>
|
||||
|
// <GEN_ROW_CNT>?</GEN_ROW_CNT>
|
||||
|
// </IF_STCK_HST>
|
||||
|
// </yerp:YERP_010_OA1_MT>
|
||||
|
// </soapenv:Body>
|
||||
|
//</soapenv:Envelope>
|
||||
|
|
||||
|
// 过滤时间为上个月
|
||||
|
var beginPeriod = "2023-06-01";// Dates.AddMonths(-1).AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-06-01";
|
||||
|
var endPeriod = "2023-07-01";// Dates.AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-07-01";
|
||||
|
string sqls = @"
|
||||
|
|
||||
|
select convert(nvarchar(10),getdate(),112) IF_STD_DATE, |
||||
|
convert(nvarchar(10),getdate(),112) STCK_STD_DATE, |
||||
|
cWhCode WRHS_CD, |
||||
|
a.cInvCode ITEM_CD, |
||||
|
cBatch PRDT_BTCH_NO, |
||||
|
'EOH' STCK_TYPE_CD, |
||||
|
iQuantity STCK_QTY, |
||||
|
0 STCK_VALUE_CNW, |
||||
|
'' STCK_VALUE_UOM, |
||||
|
(case when cInvStd is null then null else (CASE WHEN ISNUMERIC(left(cinvstd,3)) = 1 THEN REPLACE(SUBSTRING(cinvstd, 1, CHARINDEX('/', cinvstd) - 1),left(cinvstd,3),'') ELSE (CASE WHEN ISNUMERIC(left(cinvstd,2)) = 1 |
||||
|
THEN REPLACE(SUBSTRING(cinvstd, 1, CHARINDEX('/', cinvstd) - 1),left(cinvstd,2),'') ELSE (CASE WHEN ISNUMERIC(left(cinvstd,1)) = 1 |
||||
|
THEN REPLACE(SUBSTRING(cinvstd, 1, CHARINDEX('/', cinvstd) - 1),left(cinvstd,1),'') ELSE '' END) END) END) end) STCK_UOM, |
||||
|
cInvStd PACK_MIN_QTY, |
||||
|
COUNT(*) OVER (PARTITION BY getdate()) GEN_ROW_CNT |
||||
|
from CurrentStock a |
||||
|
left join dbo.Inventory c on a.cInvCode=c.cInvCode |
||||
|
where 1 = 1 and iQuantity > 0";//and dInvCreateDatetime > '{0}' and dInvCreateDatetime < '{1}'
|
||||
|
|
||||
|
sqls = string.Format(sqls, beginPeriod, endPeriod); |
||||
|
log.Info("YERP_010 sql:" + sqls); |
||||
|
DataTable vbsdt = ICSHelper.ExecuteTable(conStr, sqls); |
||||
|
log.Info("YERP_010 sql结果数量" + vbsdt.Rows.Count); |
||||
|
if (vbsdt.Rows.Count > 0) |
||||
|
{ |
||||
|
StringBuilder soapRequestData = new StringBuilder(); |
||||
|
soapRequestData.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:yerp=\"http://skch.com/YERP_010_IF_STCK_HST\">"); |
||||
|
|
||||
|
soapRequestData.Append("<soapenv:Header/>"); |
||||
|
soapRequestData.Append("<soapenv:Body>"); |
||||
|
soapRequestData.Append("<yerp:YERP_010_OA1_MT>"); |
||||
|
//循环数据 STCK_STD_DATE STCK_TYPE_CD STCK_VALUE_CNW
|
||||
|
foreach (DataRow itemRow in vbsdt.Rows) |
||||
|
{ |
||||
|
soapRequestData.Append("<!--Zero or more repetitions: -->"); |
||||
|
soapRequestData.Append("<IF_STCK_HST>"); |
||||
|
soapRequestData.Append(itemRow["IF_STD_DATE"] != null ? "<IF_STD_DATE>" + itemRow["IF_STD_DATE"].ToString() + "</IF_STD_DATE>" : "<IF_STD_DATE>" + "</IF_STD_DATE>"); |
||||
|
soapRequestData.Append(itemRow["STCK_STD_DATE"] != null ? "<STCK_STD_DATE>" + itemRow["STCK_STD_DATE"].ToString() + "</STCK_STD_DATE>" : "<STCK_STD_DATE>" + "</STCK_STD_DATE>"); |
||||
|
soapRequestData.Append(itemRow["WRHS_CD"] != null ? "<WRHS_CD>" + itemRow["WRHS_CD"].ToString() + "</WRHS_CD>" : "<WRHS_CD>" + "</WRHS_CD>"); |
||||
|
soapRequestData.Append(itemRow["ITEM_CD"] != null ? "<ITEM_CD>" + itemRow["ITEM_CD"].ToString() + "</ITEM_CD>" : "<ITEM_CD>" + "</ITEM_CD>"); |
||||
|
soapRequestData.Append(itemRow["PRDT_BTCH_NO"] != null ? "<PRDT_BTCH_NO>" + itemRow["PRDT_BTCH_NO"].ToString() + "</PRDT_BTCH_NO>" : "<PRDT_BTCH_NO>" + "</PRDT_BTCH_NO>"); |
||||
|
soapRequestData.Append(itemRow["STCK_TYPE_CD"] != null ? "<STCK_TYPE_CD>" + itemRow["STCK_TYPE_CD"].ToString() + "</STCK_TYPE_CD>" : "<STCK_TYPE_CD>" + "</STCK_TYPE_CD>"); |
||||
|
soapRequestData.Append(itemRow["STCK_QTY"] != null ? "<STCK_QTY>" + itemRow["STCK_QTY"].ToString() + "</STCK_QTY>" : "<STCK_QTY>" + "</STCK_QTY>"); |
||||
|
soapRequestData.Append(itemRow["STCK_VALUE_CNW"] != null ? "<STCK_VALUE_CNW>" + itemRow["STCK_VALUE_CNW"].ToString() + "</STCK_VALUE_CNW>" : "<STCK_VALUE_CNW>" + "</STCK_VALUE_CNW>"); |
||||
|
soapRequestData.Append(itemRow["STCK_UOM"] != null ? "<STCK_UOM>" + itemRow["STCK_UOM"].ToString() + "</STCK_UOM>" : "<STCK_UOM>" + "</STCK_UOM>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["PACK_MIN_QTY"] != null ? "<PACK_MIN_QTY>" + Regex.Replace(itemRow["PACK_MIN_QTY"].ToString(), @"[^0-9]+", "") + "</PACK_MIN_QTY>" : "<PACK_MIN_QTY>" + "</PACK_MIN_QTY>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["GEN_ROW_CNT"] != null ? "<GEN_ROW_CNT>" + itemRow["GEN_ROW_CNT"].ToString() + "</GEN_ROW_CNT>" : "<GEN_ROW_CNT>" + "</GEN_ROW_CNT>"); |
||||
|
soapRequestData.Append("</IF_STCK_HST>"); |
||||
|
} |
||||
|
|
||||
|
soapRequestData.Append("</yerp:YERP_010_OA1_MT>"); |
||||
|
soapRequestData.Append("</soapenv:Body>"); |
||||
|
soapRequestData.Append("</soapenv:Envelope>"); |
||||
|
string postData = soapRequestData.ToString(); |
||||
|
log.Info("YERP_010 xmlRequest:" + postData); |
||||
|
|
||||
|
string statusCode; |
||||
|
string resultContent; |
||||
|
|
||||
|
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072; |
||||
|
RestOpHelper rop = new RestOpHelper(); |
||||
|
rop.Clientp12path = @"C:\Users\Administrator\Desktop\yonyou-cert\wildcard.pfx"; |
||||
|
rop.Clientp12PassWord = "Yonyou2024!"; |
||||
|
rop.Url = @"https://yerp-proxy-sap-dev.skchemicals.com/XISOAPAdapter/MessageServlet?senderParty=&senderService=YERP_D&receiverParty=&receiverService=&interface=YERP_010_OA1_SI&interfaceNamespace=http://skch.com/YERP_010_IF_STCK_HST"; |
||||
|
rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); |
||||
|
|
||||
|
log.Info("YERP_010 statusCode:" + statusCode + "\r\n" + "resultContent:" + resultContent); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
log.Error(ex.ToString()); |
||||
|
} |
||||
|
} |
||||
|
public static Configuration GetConfig() |
||||
|
{ |
||||
|
Assembly assembly = Assembly.GetCallingAssembly(); |
||||
|
string path = string.Format("{0}.config", assembly.Location); |
||||
|
if (!File.Exists(path)) |
||||
|
{ |
||||
|
throw new FileNotFoundException(path + "路径下的文件未找到!"); |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(); |
||||
|
configFile.ExeConfigFilename = path; |
||||
|
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None); |
||||
|
return config; |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,146 @@ |
|||||
|
using Quartz; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Data; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Reflection; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace ICSSoft.FromERP |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Account master(交易商主数据)
|
||||
|
/// </summary>
|
||||
|
public class YERP_011 : 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 async void Execute() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
Configuration config = GetConfig(); |
||||
|
|
||||
|
var Dates = DateTime.Now; |
||||
|
string conStr = ICSHelper.GetConnectString(); |
||||
|
//<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:yerp="http://skch.com/YERP_011_IF_ACNT_INFO">
|
||||
|
// <soapenv:Header/>
|
||||
|
// <soapenv:Body>
|
||||
|
// <yerp:YERP_011_OA1_MT>
|
||||
|
// <!--Zero or more repetitions:-->
|
||||
|
// <IF_ACNT_MST>
|
||||
|
// <IF_STD_DATE>2</IF_STD_DATE>
|
||||
|
// <ACNT_CD>2</ACNT_CD>
|
||||
|
// <ACNT_NM>2</ACNT_NM>
|
||||
|
// <!--Optional:-->
|
||||
|
// <MODIFY_DTTM>2</MODIFY_DTTM>
|
||||
|
// <GEN_ROW_CNT>2</GEN_ROW_CNT>
|
||||
|
// </IF_ACNT_MST>
|
||||
|
// </yerp:YERP_011_OA1_MT>
|
||||
|
// </soapenv:Body>
|
||||
|
//</soapenv:Envelope>
|
||||
|
// 过滤时间为上个月
|
||||
|
var beginPeriod = "2000-06-01";// Dates.AddMonths(-1).AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-06-01";
|
||||
|
var endPeriod = "2090-06-01";// Dates.AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-07-01";
|
||||
|
string sqls = @"select convert(nvarchar(10),getdate(),112) IF_STD_DATE,
|
||||
|
cCusCode ACNT_CD, |
||||
|
cCusName ACNT_NM, |
||||
|
(case when dEndDate is null then '否' else '是' end) DEL_YN, |
||||
|
dCusCreateDatetime CREATE_DTTM, |
||||
|
cCreatePerson CREATE_BY, |
||||
|
dModifyDate MODIFY_DTTM, |
||||
|
cModifyPerson MODIFY_BY, |
||||
|
COUNT(*) OVER (PARTITION BY getdate()) GEN_ROW_CNT |
||||
|
from dbo.Customer a WHERE 1 = 1 and dCusCreateDatetime >= '{0}' and dCusCreateDatetime < '{1}'";
|
||||
|
sqls = string.Format(sqls, beginPeriod, endPeriod); |
||||
|
log.Info("YERP_011 sql:"+sqls); |
||||
|
DataTable vbsdt = ICSHelper.ExecuteTable(conStr, sqls); |
||||
|
log.Info("YERP_011 sql结果数量" + vbsdt.Rows.Count); |
||||
|
if (vbsdt.Rows.Count > 0) |
||||
|
{ |
||||
|
StringBuilder soapRequestData = new StringBuilder(); |
||||
|
soapRequestData.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:yerp=\"http://skch.com/YERP_011_IF_ACNT_INFO\">"); |
||||
|
soapRequestData.Append("<soapenv:Header/>"); |
||||
|
soapRequestData.Append("<soapenv:Body>"); |
||||
|
soapRequestData.Append("<yerp:YERP_011_OA1_MT>"); |
||||
|
//循环数据
|
||||
|
foreach (DataRow itemRow in vbsdt.Rows) |
||||
|
{ |
||||
|
soapRequestData.Append("<!--Zero or more repetitions: -->"); |
||||
|
soapRequestData.Append("<IF_ACNT_MST>"); |
||||
|
soapRequestData.Append(itemRow["IF_STD_DATE"] != null ? "<IF_STD_DATE>" + itemRow["IF_STD_DATE"].ToString() + "</IF_STD_DATE>" : "<IF_STD_DATE>" + "</IF_STD_DATE>"); |
||||
|
soapRequestData.Append(itemRow["ACNT_CD"] != null ? "<ACNT_CD>" + itemRow["ACNT_CD"].ToString() + "</ACNT_CD>" : "<ACNT_CD>" + "</ACNT_CD>"); |
||||
|
soapRequestData.Append(itemRow["ACNT_NM"] != null ? "<ACNT_NM>" + itemRow["ACNT_NM"].ToString() + "</ACNT_NM>" : "<ACNT_NM>" + "</ACNT_NM>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["MODIFY_DTTM"] != null ? "<MODIFY_DTTM>" + itemRow["MODIFY_DTTM"].ToString() + "</MODIFY_DTTM>" : "<MODIFY_DTTM>" + "</MODIFY_DTTM>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["GEN_ROW_CNT"] != null ? "<GEN_ROW_CNT>" + itemRow["GEN_ROW_CNT"].ToString() + "</GEN_ROW_CNT>" : "<GEN_ROW_CNT>" + "</GEN_ROW_CNT>"); |
||||
|
soapRequestData.Append("</IF_ACNT_MST>"); |
||||
|
} |
||||
|
|
||||
|
soapRequestData.Append("</yerp:YERP_011_OA1_MT>"); |
||||
|
soapRequestData.Append("</soapenv:Body>"); |
||||
|
soapRequestData.Append("</soapenv:Envelope>"); |
||||
|
string postData = soapRequestData.ToString(); |
||||
|
log.Info("YERP_011 xmlRequest:" + postData); |
||||
|
|
||||
|
string statusCode; |
||||
|
string resultContent; |
||||
|
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072; |
||||
|
RestOpHelper rop = new RestOpHelper(); |
||||
|
rop.Clientp12path = @"C:\Users\Administrator\Desktop\yonyou-cert\wildcard.pfx"; |
||||
|
rop.Clientp12PassWord = "Yonyou2024!"; |
||||
|
rop.Url = @"https://yerp-proxy-sap-dev.skchemicals.com/XISOAPAdapter/MessageServlet?senderParty=&senderService=YERP_D&receiverParty=&receiverService=&interface=YERP_011_OA1_SI&interfaceNamespace=http://skch.com/YERP_011_IF_ACNT_INFO"; |
||||
|
rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); |
||||
|
|
||||
|
log.Info("YERP_011 statusCode:" + statusCode + "\r\n" + "resultContent:" + resultContent); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
log.Error(ex.ToString()); |
||||
|
} |
||||
|
} |
||||
|
public static Configuration GetConfig() |
||||
|
{ |
||||
|
Assembly assembly = Assembly.GetCallingAssembly(); |
||||
|
string path = string.Format("{0}.config", assembly.Location); |
||||
|
if (!File.Exists(path)) |
||||
|
{ |
||||
|
throw new FileNotFoundException(path + "路径下的文件未找到!"); |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(); |
||||
|
configFile.ExeConfigFilename = path; |
||||
|
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None); |
||||
|
return config; |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,178 @@ |
|||||
|
using Quartz; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Configuration; |
||||
|
using System.Data; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Reflection; |
||||
|
using System.Text; |
||||
|
using System.Text.RegularExpressions; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace ICSSoft.FromERP |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Sales performance(销售业绩)
|
||||
|
/// </summary>
|
||||
|
public class YERP_012 : 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 async void Execute() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
Configuration config = GetConfig(); |
||||
|
|
||||
|
var Dates = DateTime.Now; |
||||
|
string conStr = ICSHelper.GetConnectString(); |
||||
|
//<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:yerp="http://skch.com/YERP_012_IF_SALES_ACT">
|
||||
|
// <soapenv:Header/>
|
||||
|
// <soapenv:Body>
|
||||
|
// <yerp:YERP_012_OA1_MT>
|
||||
|
// <!--Zero or more repetitions:-->
|
||||
|
// <IF_ACT_SALES>
|
||||
|
// <IF_STD_DATE>?</IF_STD_DATE>
|
||||
|
// <INVOICE_DATE>?</INVOICE_DATE>
|
||||
|
// <ITEM_CD>2</ITEM_CD>
|
||||
|
// <ITEM_NM>3</ITEM_NM>
|
||||
|
// <SKU_PAYMT_QTY>3</SKU_PAYMT_QTY>
|
||||
|
// <SKU_PAYMT_QTY_UOM>4</SKU_PAYMT_QTY_UOM>
|
||||
|
// <PAYMT_PRICE>5</PAYMT_PRICE>
|
||||
|
// <SALES_SITE_CD>5</SALES_SITE_CD>
|
||||
|
// <SALES_SITE_NM>5</SALES_SITE_NM>
|
||||
|
// <!--Optional:-->
|
||||
|
// <CREATE_BY>?</CREATE_BY>
|
||||
|
// <GEN_ROW_CNT>?</GEN_ROW_CNT>
|
||||
|
// </IF_ACT_SALES>
|
||||
|
// </yerp:YERP_012_OA1_MT>
|
||||
|
// </soapenv:Body>
|
||||
|
//</soapenv:Envelope>
|
||||
|
|
||||
|
// 过滤时间为上个月
|
||||
|
var beginPeriod = "2023-06-01";// Dates.AddMonths(-1).AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-06-01";
|
||||
|
var endPeriod = "2023-07-01";// Dates.AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-07-01";
|
||||
|
string sqls = @"select
|
||||
|
convert(nvarchar(10),getdate(),112) IF_STD_DATE, |
||||
|
convert(nvarchar(10),a.dDate,111) INVOICE_DATE, |
||||
|
dDate ACNTNG_DATE, |
||||
|
b.cInvCode ITEM_CD, |
||||
|
c.cInvName ITEM_NM, |
||||
|
iQuantity SKU_PAYMT_QTY, |
||||
|
d.cComUnitName SKU_PAYMT_QTY_UOM, |
||||
|
a.cCusCode SALES_SITE_CD, |
||||
|
e.cCusName SALES_SITE_NM, |
||||
|
dcreatesystime CREATE_DTTM, |
||||
|
b.iNatSum PAYMT_PRICE, |
||||
|
cMaker CREATE_BY, |
||||
|
dmodifysystime MODIFY_DTTM, |
||||
|
cmodifier MODIFY_BY, |
||||
|
COUNT(*) OVER (PARTITION BY getdate()) GEN_ROW_CNT |
||||
|
from dbo.SO_SOMain a left join dbo.SO_SODetails b on a.ID=b.ID |
||||
|
left join dbo.Inventory c on b.cInvCode=c.cInvCode |
||||
|
left join dbo.ComputationUnit d on c.cComUnitCode=d.cComunitCode |
||||
|
left join dbo.Customer e on a.cCusCode=e.cCusCode |
||||
|
WHERE 1 = 1 and dcreatesystime > '{0}' and dcreatesystime < '{1}'";//
|
||||
|
|
||||
|
sqls = string.Format(sqls, beginPeriod, endPeriod); |
||||
|
log.Info("YERP_012 sql:" + sqls); |
||||
|
DataTable vbsdt = ICSHelper.ExecuteTable(conStr, sqls); |
||||
|
log.Info("YERP_012 sql结果数量" + vbsdt.Rows.Count); |
||||
|
if (vbsdt.Rows.Count > 0) |
||||
|
{ |
||||
|
StringBuilder soapRequestData = new StringBuilder(); |
||||
|
soapRequestData.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:yerp=\"http://skch.com/YERP_012_IF_SALES_ACT\">"); |
||||
|
soapRequestData.Append("<soapenv:Header/>"); |
||||
|
soapRequestData.Append("<soapenv:Body>"); |
||||
|
soapRequestData.Append("<yerp:YERP_012_OA1_MT>"); |
||||
|
//循环数据 PAYMT_PRICE INVOICE_DATE GEN_ROW_CNT
|
||||
|
foreach (DataRow itemRow in vbsdt.Rows) |
||||
|
{ |
||||
|
soapRequestData.Append("<!--Zero or more repetitions: -->"); |
||||
|
soapRequestData.Append("<IF_ACT_SALES>"); |
||||
|
soapRequestData.Append(itemRow["IF_STD_DATE"] != null ? "<IF_STD_DATE>" + itemRow["IF_STD_DATE"].ToString() + "</IF_STD_DATE>" : "<IF_STD_DATE>" + "</IF_STD_DATE>"); |
||||
|
soapRequestData.Append(itemRow["INVOICE_DATE"] != null ? "<INVOICE_DATE>" + itemRow["INVOICE_DATE"].ToString() + "</INVOICE_DATE>" : "<INVOICE_DATE>" + "</INVOICE_DATE>"); |
||||
|
soapRequestData.Append(itemRow["ITEM_CD"] != null ? "<ITEM_CD>" + itemRow["ITEM_CD"].ToString() + "</ITEM_CD>" : "<ITEM_CD>" + "</ITEM_CD>"); |
||||
|
soapRequestData.Append(itemRow["ITEM_NM"] != null ? "<ITEM_NM>" + itemRow["ITEM_NM"].ToString() + "</ITEM_NM>" : "<ITEM_NM>" + "</ITEM_NM>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["SKU_PAYMT_QTY"] != null ? "<SKU_PAYMT_QTY>" + itemRow["SKU_PAYMT_QTY"].ToString() + "</SKU_PAYMT_QTY>" : "<SKU_PAYMT_QTY>" + "</SKU_PAYMT_QTY>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["SKU_PAYMT_QTY_UOM"] != null ? "<SKU_PAYMT_QTY_UOM>" + itemRow["SKU_PAYMT_QTY_UOM"].ToString() + "</SKU_PAYMT_QTY_UOM>" : "<SKU_PAYMT_QTY_UOM>" + "</SKU_PAYMT_QTY_UOM>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["SALES_SITE_CD"] != null ? "<SALES_SITE_CD>" + itemRow["SALES_SITE_CD"].ToString() + "</SALES_SITE_CD>" : "<SALES_SITE_CD>" + "</SALES_SITE_CD>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["SALES_SITE_NM"] != null ? "<SALES_SITE_NM>" + itemRow["SALES_SITE_NM"].ToString() + "</SALES_SITE_NM>" : "<SALES_SITE_NM>" + "</SALES_SITE_NM>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["PAYMT_PRICE"] != null ? "<PAYMT_PRICE>" + itemRow["PAYMT_PRICE"].ToString() + "</PAYMT_PRICE>" : "<PAYMT_PRICE>" + "</PAYMT_PRICE>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["CREATE_BY"] != null ? "<CREATE_BY>" + itemRow["CREATE_BY"].ToString() + "</CREATE_BY>" : "<CREATE_BY>" + "</CREATE_BY>"); |
||||
|
soapRequestData.Append("<!--Optional:-->"); |
||||
|
soapRequestData.Append(itemRow["GEN_ROW_CNT"] != null ? "<GEN_ROW_CNT>" + itemRow["GEN_ROW_CNT"].ToString() + "</GEN_ROW_CNT>" : "<GEN_ROW_CNT>" + "</GEN_ROW_CNT>"); |
||||
|
soapRequestData.Append("</IF_ACT_SALES>"); |
||||
|
} |
||||
|
|
||||
|
soapRequestData.Append("</yerp:YERP_012_OA1_MT>"); |
||||
|
soapRequestData.Append("</soapenv:Body>"); |
||||
|
soapRequestData.Append("</soapenv:Envelope>"); |
||||
|
string postData = soapRequestData.ToString(); |
||||
|
log.Info("YERP_012 xmlRequest:" + postData); |
||||
|
|
||||
|
string statusCode; |
||||
|
string resultContent; |
||||
|
|
||||
|
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072; |
||||
|
RestOpHelper rop = new RestOpHelper(); |
||||
|
rop.Clientp12path = @"C:\Users\Administrator\Desktop\yonyou-cert\wildcard.pfx"; |
||||
|
rop.Clientp12PassWord = "Yonyou2024!"; |
||||
|
rop.Url = @"https://yerp-proxy-sap-dev.skchemicals.com/XISOAPAdapter/MessageServlet?senderParty=&senderService=YERP_D&receiverParty=&receiverService=&interface=YERP_012_OA1_SI&interfaceNamespace=http://skch.com/YERP_012_IF_SALES_ACT"; |
||||
|
rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); |
||||
|
|
||||
|
log.Info("YERP_012 statusCode:" + statusCode + "\r\n" + "resultContent:" + resultContent); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
log.Error(ex.ToString()); |
||||
|
} |
||||
|
} |
||||
|
public static Configuration GetConfig() |
||||
|
{ |
||||
|
Assembly assembly = Assembly.GetCallingAssembly(); |
||||
|
string path = string.Format("{0}.config", assembly.Location); |
||||
|
if (!File.Exists(path)) |
||||
|
{ |
||||
|
throw new FileNotFoundException(path + "路径下的文件未找到!"); |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(); |
||||
|
configFile.ExeConfigFilename = path; |
||||
|
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None); |
||||
|
return config; |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,111 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Xml.Linq; |
||||
|
|
||||
|
namespace ICSSoft.FromERP |
||||
|
{ |
||||
|
public static class XmlAPIHelper |
||||
|
{ |
||||
|
private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
||||
|
|
||||
|
|
||||
|
public static string GetERPUrl() |
||||
|
{ |
||||
|
return System.Configuration.ConfigurationManager.AppSettings["ERPUrl"]; |
||||
|
} |
||||
|
|
||||
|
public static string RequestXML(string url, string xmlData) |
||||
|
{ |
||||
|
log.Debug(url); |
||||
|
string statusCode = "400"; |
||||
|
string resultContent = ""; |
||||
|
try |
||||
|
{ |
||||
|
log.Debug(xmlData); |
||||
|
byte[] bytes = Encoding.UTF8.GetBytes(xmlData); |
||||
|
|
||||
|
////Basic Auth
|
||||
|
//byte[] byteUser = Encoding.Default.GetBytes(userName + ":" + password);
|
||||
|
//string Authorization = Convert.ToBase64String(byteUser);
|
||||
|
|
||||
|
WebRequest request = HttpWebRequest.Create(url); |
||||
|
//避免远程连接证书无效问题
|
||||
|
ServicePointManager.ServerCertificateValidationCallback = (s, certificate, chain, errs) => true; |
||||
|
request.Method = "POST"; |
||||
|
request.Timeout = 300000; |
||||
|
request.ContentType = "text/xml;charset=UTF-8"; |
||||
|
request.ContentLength = bytes.Length; |
||||
|
//request.Headers.Add("Authorization", "Basic " + Authorization);
|
||||
|
//根据soapui中的SOAPAction 进行赋值
|
||||
|
request.Headers.Add("SOAPAction", "\"\""); |
||||
|
Stream requestStream = request.GetRequestStream(); |
||||
|
requestStream.Write(bytes, 0, bytes.Length); |
||||
|
requestStream.Close(); |
||||
|
HttpWebResponse response = request.GetResponse() as HttpWebResponse; |
||||
|
statusCode = response.StatusCode.ToString("d"); |
||||
|
Stream responseStream = response.GetResponseStream(); |
||||
|
StreamReader sr = new StreamReader(responseStream, Encoding.UTF8); |
||||
|
resultContent = sr.ReadToEnd(); |
||||
|
sr.Dispose(); |
||||
|
responseStream.Close(); |
||||
|
//response.Dispose();
|
||||
|
log.Debug(resultContent); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
log.Error(ex.ToString()); |
||||
|
statusCode = "400"; |
||||
|
resultContent = ex.Message; |
||||
|
//throw ex;
|
||||
|
} |
||||
|
return resultContent; |
||||
|
} |
||||
|
|
||||
|
public static string GetData(string Operation, XElement document) |
||||
|
{ |
||||
|
string result = string.Empty; |
||||
|
try |
||||
|
{ |
||||
|
XNamespace soapenvNamespace = "http://schemas.xmlsoap.org/soap/envelope/"; |
||||
|
XNamespace tipNamespace = "http://www.dsc.com.tw/tiptop/TIPTOPServiceGateWay"; |
||||
|
|
||||
|
XElement root = new XElement(soapenvNamespace + "Envelope", |
||||
|
new XAttribute(XNamespace.Xmlns + "soapenv", soapenvNamespace), |
||||
|
new XAttribute(XNamespace.Xmlns + "tip", tipNamespace), |
||||
|
new XElement(soapenvNamespace + "Header"), |
||||
|
new XElement(soapenvNamespace + "Body", |
||||
|
new XElement(tipNamespace + Operation + "Request", |
||||
|
new XElement(tipNamespace + "request", |
||||
|
new XElement("Request", |
||||
|
new XElement("Access", |
||||
|
new XElement("Authentication", new XAttribute("user", "kc"), new XAttribute("password", "kckckc258")), |
||||
|
new XElement("Connection", new XAttribute("application", "ERP"), new XAttribute("source", "10.0.0.196")), |
||||
|
new XElement("Organization", new XAttribute("name", "KC47")), |
||||
|
new XElement("Locale", new XAttribute("language", "zh_cn")) |
||||
|
), |
||||
|
new XElement("RequestContent", |
||||
|
new XElement("Parameter"), |
||||
|
document |
||||
|
) |
||||
|
) |
||||
|
) |
||||
|
) |
||||
|
) |
||||
|
); |
||||
|
result = root.ToString().Replace("<tip:request>\r\n <Request>", "<tip:request><![CDATA[<Request>") |
||||
|
.Replace("</Request>\r\n </tip:request>", "</Request>]]></tip:request>"); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
log.Error(ex.ToString()); |
||||
|
throw ex; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue