From 1608fb374ed9307d7b2ded38fd71a6f8da6ddb5e Mon Sep 17 00:00:00 2001 From: "shiqian.wang" Date: Fri, 23 Aug 2024 16:13:53 +0800 Subject: [PATCH] =?UTF-8?q?SK=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ICSSoft.FromERP/ICSSoft.FromERP.csproj | 3 + ICSSoft.FromERP/SK/YERP_002.cs | 228 +++++++++++++++++++++ ICSSoft.FromERP/SK/YERP_003.cs | 166 ++++++++++++++++ ICSSoft.FromERP/SK/YERP_004.cs | 261 +++++++++++++++++++++++++ ICSSoft.FromERP/SK/YERP_007.cs | 2 +- 5 files changed, 659 insertions(+), 1 deletion(-) create mode 100644 ICSSoft.FromERP/SK/YERP_002.cs create mode 100644 ICSSoft.FromERP/SK/YERP_003.cs create mode 100644 ICSSoft.FromERP/SK/YERP_004.cs diff --git a/ICSSoft.FromERP/ICSSoft.FromERP.csproj b/ICSSoft.FromERP/ICSSoft.FromERP.csproj index 5864f8e..6c68e06 100644 --- a/ICSSoft.FromERP/ICSSoft.FromERP.csproj +++ b/ICSSoft.FromERP/ICSSoft.FromERP.csproj @@ -154,6 +154,9 @@ + + + diff --git a/ICSSoft.FromERP/SK/YERP_002.cs b/ICSSoft.FromERP/SK/YERP_002.cs new file mode 100644 index 0000000..402d3dd --- /dev/null +++ b/ICSSoft.FromERP/SK/YERP_002.cs @@ -0,0 +1,228 @@ +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 +{ + /// + /// 销售发票列表 + /// + public class YERP_002 : 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; + string conStr = ICSHelper.GetConnectString(); + // 202404 + // 过滤时间为上个月 + string Date = Dates.ToString("yyyy"); + string Muoth = Dates.AddMonths(-1).ToString("MM"); + string Day = Dates.ToString("dd"); + // + // + // + // + // + // + // + // ? + // ? + // ? + // ? + // ? + // ? + // ? + // ? + // ? + // ? + // + // ? + // + // ? + // ? + // ? + // ? + // + // ? + // ? + // + // ? + // ? + // ? + // ? + // ? + // ? + // ? + // + // ? + // + // ? + // + // ? + // ? + // ? + // + // ? + // + // ? + // + // ? + // + // ? + // ? + // ? + // + // + // + // + var beginPeriod = "2023-07-01";// Dates.AddMonths(-1).AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-06-01"; + var endPeriod = "2023-08-01";// Dates.AddDays(-Dates.Day + 1).ToString("yyyy-MM-dd");//"2023-07-01"; + string sqls = @" +select b.cSOCode P_ORDER_NUM,cBusType BIZ_TYP,cSTName SL_TYP,cSBVCode INVC_NO,dDate INVC_DE,cDLCode DO_NO,cCusCode CUST_CD,cCusName CUST_NM,cexch_name CUR,iExchRate ER, +cDepName SL_TEAM, cPsn_Name SL_PIC,cWhCode WH, b.cInvCode INVT_CD, c.cInvAddCode INVT_ACD, c.cInvName INVT_NM, c.cInvStd STDD_MDL, b.iQuantity QTY, b.iQuotedPrice STMT, iTaxUnitPrice PRTX_UPRC, +iUnitPrice FRTX_UPRC, iMoney FRTX_AMT,b.iTaxRate TXRTO, iTax TX_AMT,iSum PRTX_AMT, KL DISRTO1,KL2 DISRTO2, iDisCount DIS_AMT,cMaker CRTR, cChecker REVR,a.csscode STTL_TYP_CD, a.cSCCode DLVR_TYP_CD, +d.cSCName DLVR_TYP, cSSName STTL_TYP, +iSum - iExchSum OUTST_AMT, --原币价税合计 - 累计原币收款金额 +iNatSum - iMoneySum OUTST_LCUR, --本币价税合计-累计本币收款金额 +0 Printnum,a.dDate +from dbo.SaleBillVouch a left join dbo.SaleBillVouchs b on A.SBVID = B.SBVID +left join dbo.Inventory c on b.cInvCode = c.cInvCode +left join dbo.ShippingChoice d on a.cSCCode = d.cSCCode +left join dbo.SettleStyle e on a.csscode = e.cSSCode +left join dbo.SaleType f on a.cSTCode = f.cSTCode +left join dbo.hr_hi_person h on a.cPersonCode = h.cPsn_Num +left join dbo.Department j on j.cDepCode = a.cDepCode WHERE 1 = 1 and a.dDate >= '{0}' and a.dDate <= '{1}'"; + sqls = string.Format(sqls, beginPeriod, endPeriod); + log.Info("YERP_002 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(""); + soapRequestData.Append(""); + soapRequestData.Append(""); + soapRequestData.Append(""); + //循环数据 + foreach (DataRow itemRow in vbsdt.Rows) + { + //原循环部分 begin + soapRequestData.Append(""); + soapRequestData.Append(itemRow["P_ORDER_NUM"] != null ? "" + itemRow["P_ORDER_NUM"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["BIZ_TYP"] != null ? "" + itemRow["BIZ_TYP"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["SL_TYP"] != null ? "" + itemRow["SL_TYP"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["INVC_NO"] != null ? "" + itemRow["INVC_NO"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["INVC_DE"] != null ? "" + itemRow["INVC_DE"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DO_NO"] != null ? "" + itemRow["DO_NO"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["CUST_CD"] != null ? "" + itemRow["CUST_CD"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["CUST_NM"] != null ? "" + itemRow["CUST_NM"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["CUR"] != null ? "" + itemRow["CUR"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["ER"] != null ? "" + itemRow["ER"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["SL_TEAM"] != null ? "" + itemRow["SL_TEAM"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["SL_PIC"] != null ? "" + itemRow["SL_PIC"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["WH"] != null ? "" + itemRow["WH"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["INVT_CD"] != null ? "" + itemRow["INVT_CD"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["INVT_NM"] != null ? "" + itemRow["INVT_NM"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["STDD_MDL"] != null ? "" + Regex.Replace(itemRow["STDD_MDL"].ToString(), @"[^0-9]+", "") + "" : "" + ""); + soapRequestData.Append(itemRow["QTY"] != null ? "" + itemRow["QTY"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["STMT"] != null ? "" + itemRow["STMT"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["PRTX_UPRC"] != null ? "" + itemRow["PRTX_UPRC"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["FRTX_UPRC"] != null ? "" + itemRow["FRTX_UPRC"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["FRTX_AMT"] != null ? "" + itemRow["FRTX_AMT"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["TXRTO"] != null ? "" + itemRow["TXRTO"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["TX_AMT"] != null ? "" + itemRow["TX_AMT"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["PRTX_AMT"] != null ? "" + itemRow["PRTX_AMT"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DISRTO1"] != null ? "" + itemRow["DISRTO1"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DISRTO2"] != null ? "" + itemRow["DISRTO2"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DIS_AMT"] != null ? "" + itemRow["DIS_AMT"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["CRTR"] != null ? "" + itemRow["CRTR"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["REVR"] != null ? "" + itemRow["REVR"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["STTL_TYP_CD"] != null ? "" + itemRow["STTL_TYP_CD"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DLVR_TYP_CD"] != null ? "" + itemRow["DLVR_TYP_CD"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DLVR_TYP"] != null ? "" + itemRow["DLVR_TYP"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["STTL_TYP"] != null ? "" + itemRow["STTL_TYP"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["OUTST_AMT"] != null ? "" + itemRow["OUTST_AMT"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["OUTST_LCUR"] != null ? "" + itemRow["OUTST_LCUR"].ToString() + "" : "" + ""); + soapRequestData.Append(""); + //原循环部分 end + } + soapRequestData.Append(""); + soapRequestData.Append(""); + soapRequestData.Append(""); + string postData = soapRequestData.ToString(); + log.Info("YERP_002 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_002_OA1_SI&interfaceNamespace=http://skch.com/YERP_002_SALES_INVOICE"; + rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); + + log.Info("YERP_002 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; + } + } + } +} diff --git a/ICSSoft.FromERP/SK/YERP_003.cs b/ICSSoft.FromERP/SK/YERP_003.cs new file mode 100644 index 0000000..45a5cfd --- /dev/null +++ b/ICSSoft.FromERP/SK/YERP_003.cs @@ -0,0 +1,166 @@ +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 +{ + /// + /// 主营业务收入明细账 + /// + public class YERP_003 : 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; + string conStr = ICSHelper.GetConnectString(); + // 202404 + // 过滤时间为上个月 + string Date = Dates.ToString("yyyy"); + string Muoth = Dates.AddMonths(-1).ToString("MM"); + string Day = Dates.ToString("dd"); + // + // + // + // + // + // + // ? + // ? + // ? + // ? + //
?
+ // ? + // ? + // ? + // + // ? + // + // ? + // ? + // ? + //
+ //
+ //
+ //
+ var beginPeriod = "202301";//Date + Muoth; + var endPeriod = "202302";//Date + Muoth; + string sqls = @" +begin transaction + +exec GL_Ledger @tblname=N'zyywsrmxz',@KmCode=N'6001',@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..zyywsrmxz where autoid<=a.autoid) BLNC from tempdb..zyywsrmxz a + +rollback transaction"; + sqls = string.Format(sqls, beginPeriod, endPeriod); + log.Info("YERP_003 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(""); + soapRequestData.Append(""); + soapRequestData.Append(""); + soapRequestData.Append(""); + //循环数据 + foreach (DataRow itemRow in vbsdt.Rows) + { + //原循环部分 begin + soapRequestData.Append(""); + soapRequestData.Append(itemRow["SBJ_CD"] != null ? "" + itemRow["SBJ_CD"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["SBJ_NM"] != null ? "" + itemRow["SBJ_NM"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["YYYY"] != null ? "" + itemRow["YYYY"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["MM"] != null ? "" + itemRow["MM"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DD"] != null ? "
" + itemRow["DD"].ToString() + "
" : "
" + "
"); + soapRequestData.Append(itemRow["SPTDOC"] != null ? "" + itemRow["SPTDOC"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["SMR"] != null ? "" + itemRow["SMR"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["ODR_ACC"] != null ? "" + itemRow["ODR_ACC"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DBTO_AMT"] != null ? "" + itemRow["DBTO_AMT"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["CRDTO_AMT"] != null ? "" + itemRow["CRDTO_AMT"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DBTO_CRDTO_DVSN"] != null ? "" + itemRow["DBTO_CRDTO_DVSN"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["BLNC"] != null ? "" + itemRow["BLNC"].ToString() + "" : "" + ""); + soapRequestData.Append("
"); + //原循环部分 end + } + soapRequestData.Append("
"); + soapRequestData.Append("
"); + soapRequestData.Append("
"); + string postData = soapRequestData.ToString(); + log.Info("YERP_003 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_003_OA1_SI&interfaceNamespace=http://skch.com/YERP_003_CORP_COMMISSION"; + rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); + + log.Info("YERP_003 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; + } + } + } +} diff --git a/ICSSoft.FromERP/SK/YERP_004.cs b/ICSSoft.FromERP/SK/YERP_004.cs new file mode 100644 index 0000000..6eff95f --- /dev/null +++ b/ICSSoft.FromERP/SK/YERP_004.cs @@ -0,0 +1,261 @@ +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 +{ + /// + /// 销售费用明细账 + /// + public class YERP_004 : 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; + string conStr = ICSHelper.GetConnectString(); + // 202404 + // 过滤时间为上个月 + string Date = Dates.ToString("yyyy"); + string Muoth = Dates.AddMonths(-1).ToString("MM"); + string Day = Dates.ToString("dd"); + // + // + // + // + // + // + // ? + // ? + //
?
+ // ? + // ? + // + // ? + // + // ? + // ? + // ? + // + // ? + // + // ? + // + // ? + // + // ? + // + // ? + // + // ? + // + // ? + // + // ? + // + // ? + //
+ //
+ //
+ //
+ var beginPeriod = "202301";//Date + Muoth; + var endPeriod = "202303";//Date + Muoth; + string sqls = @" + begin transaction + +exec GL_Ledger @tblname=N'zyywsrmxz',@KmCode=N'6601',@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,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..zyywsrmxz a + +select YYYY,SPTDOC,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..zyywsrmxz 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'6601%' or ccode_name like N'6601%' or ccode_engl like N'6601%' or chelp like N'6601%' )) and ccode <>'6601' and b.SPTDOC is null + set @i=@i +1 +end + + + set @k=@k +1 +end + + +SELECT + SPTDOC,imonth,iday, + SUM(CASE WHEN SBJ_CD = '660101' THEN DBTO_AMT ELSE 0 END) WH_CST, + SUM(CASE WHEN SBJ_CD = '660102' THEN DBTO_AMT ELSE 0 END) TRNSF_CST, + SUM(CASE WHEN SBJ_CD = '660103' THEN DBTO_AMT ELSE 0 END) XBT_CST, + SUM(CASE WHEN SBJ_CD = '660104' THEN DBTO_AMT ELSE 0 END) NLD_CST, + SUM(CASE WHEN SBJ_CD = '660105' THEN DBTO_AMT ELSE 0 END) SMPL_CST, + SUM(CASE WHEN SBJ_CD = '660106' THEN DBTO_AMT ELSE 0 END) TRNSF_AGNC_CST, + SUM(CASE WHEN SBJ_CD = '660107' THEN DBTO_AMT ELSE 0 END) ADTV, + SUM(CASE WHEN SBJ_CD = '660108' THEN DBTO_AMT ELSE 0 END) NCLSN_CST, + SUM(CASE WHEN SBJ_CD = '660109' THEN DBTO_AMT ELSE 0 END) SVC_CST + into #test9 +FROM + #test6 +GROUP BY + SPTDOC,imonth,iday + + + select YYYY,MM,DD,A.SPTDOC,SMR,DBTO_AMT DBTO,CRDTO_AMT CRDTO,INVT,BLNC,WH_CST,TRNSF_CST,XBT_CST,NLD_CST,SMPL_CST,TRNSF_AGNC_CST,ADTV,NCLSN_CST,SVC_CST from #test5 a left join #test9 b on a.SPTDOC=b.SPTDOC and a.MM=b.imonth and a.DD=b.iday + +rollback transaction +"; + sqls = string.Format(sqls, beginPeriod, endPeriod); + log.Info("YERP_004 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(""); + soapRequestData.Append(""); + soapRequestData.Append(""); + soapRequestData.Append(""); + //循环数据 + foreach (DataRow itemRow in vbsdt.Rows) + { + //原循环部分 begin + soapRequestData.Append(""); + soapRequestData.Append(itemRow["YYYY"] != null ? "" + itemRow["YYYY"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["MM"] != null ? "" + itemRow["MM"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DD"] != null ? "
" + itemRow["DD"].ToString() + "
" : "
" + "
"); + soapRequestData.Append(itemRow["SPTDOC"] != null ? "" + itemRow["SPTDOC"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["SMR"] != null ? "" + itemRow["SMR"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["DBTO"] != null ? "" + itemRow["DBTO"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["CRDTO"] != null ? "" + itemRow["CRDTO"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["INVT"] != null ? "" + itemRow["INVT"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["BLNC"] != null ? "" + itemRow["BLNC"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["WH_CST"] != null ? "" + itemRow["WH_CST"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["TRNSF_CST"] != null ? "" + itemRow["TRNSF_CST"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["XBT_CST"] != null ? "" + itemRow["XBT_CST"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["NLD_CST"] != null ? "" + itemRow["NLD_CST"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["SMPL_CST"] != null ? "" + itemRow["SMPL_CST"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["TRNSF_AGNC_CST"] != null ? "" + itemRow["TRNSF_AGNC_CST"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["ADTV"] != null ? "" + itemRow["ADTV"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["NCLSN_CST"] != null ? "" + itemRow["NCLSN_CST"].ToString() + "" : "" + ""); + soapRequestData.Append(itemRow["SVC_CST"] != null ? "" + itemRow["SVC_CST"].ToString() + "" : "" + ""); + soapRequestData.Append("
"); + //原循环部分 end + } + soapRequestData.Append("
"); + soapRequestData.Append("
"); + soapRequestData.Append("
"); + string postData = soapRequestData.ToString(); + log.Info("YERP_004 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_004_OA1_SI&interfaceNamespace=http://skch.com/YERP_004_SALES_COST_STMT"; + rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); + + log.Info("YERP_004 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; + } + } + } +} diff --git a/ICSSoft.FromERP/SK/YERP_007.cs b/ICSSoft.FromERP/SK/YERP_007.cs index 02045bb..9fd27c2 100644 --- a/ICSSoft.FromERP/SK/YERP_007.cs +++ b/ICSSoft.FromERP/SK/YERP_007.cs @@ -158,7 +158,7 @@ namespace ICSSoft.FromERP 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 + select YYYY,MM,DD,A.SPTDOC,SMR,DBTO_AMT DBTO,CRDTO_AMT CRDTO,INVT,BLNC,DBTO_CMSN,DBTO_IENS,DBTO_XCH_PC,'' DBTO_CRDTO_DVSN 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