shiqian.wang
2 months ago
3 changed files with 610 additions and 1 deletions
-
2ICSSoft.FromERP/SK/YERP_003.cs
-
357ICSSoft.FromERP/SK/YERP_006_gz.cs
-
252ICSSoft.FromERP/SK/YERP_007_gz.cs
@ -0,0 +1,357 @@ |
|||
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>
|
|||
/// 管理费用明细账
|
|||
/// </summary>
|
|||
public class YERP_006_gz : 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.GetConfigString("SysConnectionString_gz"); |
|||
if (string.IsNullOrEmpty(conStr)) |
|||
{ |
|||
log.Info("YERP_006 conStr未找到。"); |
|||
return; |
|||
} |
|||
//<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:yerp="http://skch.com/YERP_006_MATN_COST">
|
|||
// <soapenv:Header/>
|
|||
// <soapenv:Body>
|
|||
// <yerp:YERP_006_OA1_MT>
|
|||
// <!--1 or more repetitions:-->
|
|||
// <MGMT_CST>
|
|||
// <YYYY>?</YYYY>
|
|||
// <MM>?</MM>
|
|||
// <DD>?</DD>
|
|||
// <SPTDOC_NO>?</SPTDOC_NO>
|
|||
// <SMR>?</SMR>
|
|||
// <DBTO>?</DBTO>
|
|||
// <CRDTO>?</CRDTO>
|
|||
// <DBTO_CRDTO_DVSN>?</DBTO_CRDTO_DVSN>
|
|||
// <BLNC>?</BLNC>
|
|||
// <!--Optional:-->
|
|||
// <OFC_OPRT_CST>?</OFC_OPRT_CST>
|
|||
// <!--Optional:-->
|
|||
// <BZTRP_CST>?</BZTRP_CST>
|
|||
// <!--Optional:-->
|
|||
// <TRSF_CST>?</TRSF_CST>
|
|||
// <!--Optional:-->
|
|||
// <BNFT_CST>?</BNFT_CST>
|
|||
// <!--Optional:-->
|
|||
// <NTTN_CST>?</NTTN_CST>
|
|||
// <!--Optional:-->
|
|||
// <SCLISRC>?</SCLISRC>
|
|||
// <!--Optional:-->
|
|||
// <DDTN>?</DDTN>
|
|||
// <!--Optional:-->
|
|||
// <NTRR_CST>?</NTRR_CST>
|
|||
// <!--Optional:-->
|
|||
// <VEHS_OPRT_CST>?</VEHS_OPRT_CST>
|
|||
|
|||
// <!--Optional:-->
|
|||
// <SVC_CST>?</SVC_CST>
|
|||
// <!--Optional:-->
|
|||
// <VEHS_RNTL_CST>?</VEHS_RNTL_CST>
|
|||
// <!--Optional:-->
|
|||
// <OFC_RNTL_CST>?</OFC_RNTL_CST>
|
|||
// <!--Optional:-->
|
|||
// <PRPT_MGMT_CST>?</PRPT_MGMT_CST>
|
|||
// <!--Optional:-->
|
|||
// <WTNELCT_CST>?</WTNELCT_CST>
|
|||
// <!--Optional:-->
|
|||
// <NWK_CST>?</NWK_CST>
|
|||
// <!--Optional:-->
|
|||
// <TELE_CST>?</TELE_CST>
|
|||
// <!--Optional:-->
|
|||
// <MEET_CST>?</MEET_CST>
|
|||
// <!--Optional:-->
|
|||
// <PCL_CST>?</PCL_CST>
|
|||
// <!--Optional:-->
|
|||
// <PNCST>?</PNCST>
|
|||
// <!--Optional:-->
|
|||
// <CUN_CST>?</CUN_CST>
|
|||
// <!--Optional:-->
|
|||
// <DPRCT_CST>?</DPRCT_CST>
|
|||
// <!--Optional:-->
|
|||
// <EDU_CST>?</EDU_CST>
|
|||
|
|||
// <!--Optional:-->
|
|||
// <RPR_CST>?</RPR_CST>
|
|||
// <!--Optional:-->
|
|||
// <LBPRTT_CST>?</LBPRTT_CST>
|
|||
// <!--Optional:-->
|
|||
// <BZ_PRMT_CST>?</BZ_PRMT_CST>
|
|||
// <!--Optional:-->
|
|||
// <TEST_CST>?</TEST_CST>
|
|||
// <!--Optional:-->
|
|||
// <BK_CST>?</BK_CST>
|
|||
// <!--Optional:-->
|
|||
// <RCRT_CST>?</RCRT_CST>
|
|||
// <!--Optional:-->
|
|||
// <XBT_CST>?</XBT_CST>
|
|||
// <!--Optional:-->
|
|||
// <RSNB_LOS>?</RSNB_LOS>
|
|||
// </MGMT_CST>
|
|||
// </yerp:YERP_006_OA1_MT>
|
|||
// </soapenv:Body>
|
|||
//</soapenv:Envelope>
|
|||
// 202404
|
|||
// 过滤时间为上个月
|
|||
string Date = Dates.ToString("yyyy"); |
|||
string beginMuoth = Dates.AddMonths(-1).ToString("MM"); |
|||
string endMuoth = Dates.ToString("MM"); |
|||
var beginPeriod = "200001";//Date + beginMuoth
|
|||
var endPeriod = "206001";//Date + endMuoth
|
|||
string sqls = @"begin transaction
|
|||
|
|||
exec GL_Ledger @tblname=N'glfymxz',@KmCode=N'5602',@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..glfymxz a |
|||
|
|||
select 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,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..glfymxz 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'6602%' or ccode_name like N'6602%' or ccode_engl like N'6602%' or chelp like N'6602%' )) and ccode <>'6602' 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 = '660201' THEN DBTO_AMT ELSE 0 END) OFC_OPRT_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660202' THEN DBTO_AMT ELSE 0 END) BZTRP_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660203' THEN DBTO_AMT ELSE 0 END) TRSF_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660204' THEN DBTO_AMT ELSE 0 END) BNFT_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660205' THEN DBTO_AMT ELSE 0 END) NTTN_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660206' THEN DBTO_AMT ELSE 0 END) SCLISRC, |
|||
SUM(CASE WHEN SBJ_CD = '660207' THEN DBTO_AMT ELSE 0 END) DDTN, |
|||
SUM(CASE WHEN SBJ_CD = '660208' THEN DBTO_AMT ELSE 0 END) NTRR_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660209' THEN DBTO_AMT ELSE 0 END) VEHS_OPRT_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660210' THEN DBTO_AMT ELSE 0 END) SVC_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660211' THEN DBTO_AMT ELSE 0 END) VEHS_RNTL_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660212' THEN DBTO_AMT ELSE 0 END) OFC_RNTL_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660213' THEN DBTO_AMT ELSE 0 END) PRPT_MGMT_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660214' THEN DBTO_AMT ELSE 0 END) WTNELCT_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660215' THEN DBTO_AMT ELSE 0 END) NWK_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660216' THEN DBTO_AMT ELSE 0 END) TELE_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660217' THEN DBTO_AMT ELSE 0 END) MEET_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660218' THEN DBTO_AMT ELSE 0 END) PCL_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660219' THEN DBTO_AMT ELSE 0 END) PNCST, |
|||
SUM(CASE WHEN SBJ_CD = '660220' THEN DBTO_AMT ELSE 0 END) CUN_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660221' THEN DBTO_AMT ELSE 0 END) DPRCT_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660222' THEN DBTO_AMT ELSE 0 END) EDU_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660223' THEN DBTO_AMT ELSE 0 END) RPR_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660224' THEN DBTO_AMT ELSE 0 END) LBPRTT_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660225' THEN DBTO_AMT ELSE 0 END) BZ_PRMT_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660226' THEN DBTO_AMT ELSE 0 END) TEST_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660227' THEN DBTO_AMT ELSE 0 END) BK_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660228' THEN DBTO_AMT ELSE 0 END) RCRT_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660229' THEN DBTO_AMT ELSE 0 END) XBT_CST, |
|||
SUM(CASE WHEN SBJ_CD = '660230' THEN DBTO_AMT ELSE 0 END) RSNB_LOS |
|||
|
|||
into #test9 |
|||
FROM |
|||
#test6 |
|||
GROUP BY |
|||
SPTDOC,imonth,iday |
|||
|
|||
|
|||
select YYYY,MM,DD,A.SPTDOC as SPTDOC_NO,SMR,DBTO_AMT DBTO,CRDTO_AMT CRDTO,INVT as DBTO_CRDTO_DVSN,BLNC,OFC_OPRT_CST,BZTRP_CST,TRSF_CST,BNFT_CST,NTTN_CST,SCLISRC,DDTN,NTRR_CST,VEHS_OPRT_CST,SVC_CST,VEHS_RNTL_CST, |
|||
OFC_RNTL_CST,PRPT_MGMT_CST,WTNELCT_CST,NWK_CST,TELE_CST,MEET_CST,PCL_CST,PNCST,CUN_CST,DPRCT_CST,EDU_CST,RPR_CST,LBPRTT_CST,BZ_PRMT_CST,TEST_CST,BK_CST,RCRT_CST,XBT_CST,RSNB_LOS |
|||
|
|||
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 |
|||
";
|
|||
sqls = string.Format(sqls, beginPeriod, endPeriod); |
|||
log.Info("YERP_006 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_006_MATN_COST\">"); |
|||
soapRequestData.Append("<soapenv:Header/>"); |
|||
soapRequestData.Append("<soapenv:Body>"); |
|||
soapRequestData.Append("<yerp:YERP_006_OA1_MT>"); |
|||
//循环数据
|
|||
foreach (DataRow itemRow in vbsdt.Rows) |
|||
{ |
|||
//原循环部分 begin
|
|||
soapRequestData.Append("<MGMT_CST>"); |
|||
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_NO"] != null ? "<SPTDOC_NO>" + itemRow["SPTDOC_NO"].ToString() + "</SPTDOC_NO>" : "<SPTDOC_NO>" + "</SPTDOC_NO>"); |
|||
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["OFC_OPRT_CST"] != null ? "<OFC_OPRT_CST>" + itemRow["OFC_OPRT_CST"].ToString() + "</OFC_OPRT_CST>" : "<OFC_OPRT_CST>" + "</OFC_OPRT_CST>"); |
|||
soapRequestData.Append(itemRow["BZTRP_CST"] != null ? "<BZTRP_CST>" + itemRow["BZTRP_CST"].ToString() + "</BZTRP_CST>" : "<BZTRP_CST>" + "</BZTRP_CST>"); |
|||
soapRequestData.Append(itemRow["TRSF_CST"] != null ? "<TRSF_CST>" + itemRow["TRSF_CST"].ToString() + "</TRSF_CST>" : "<TRSF_CST>" + "</TRSF_CST>"); |
|||
soapRequestData.Append(itemRow["BNFT_CST"] != null ? "<BNFT_CST>" + itemRow["BNFT_CST"].ToString() + "</BNFT_CST>" : "<BNFT_CST>" + "</BNFT_CST>"); |
|||
soapRequestData.Append(itemRow["NTTN_CST"] != null ? "<NTTN_CST>" + itemRow["NTTN_CST"].ToString() + "</NTTN_CST>" : "<NTTN_CST>" + "</NTTN_CST>"); |
|||
soapRequestData.Append(itemRow["SCLISRC"] != null ? "<SCLISRC>" + itemRow["SCLISRC"].ToString() + "</SCLISRC>" : "<SCLISRC>" + "</SCLISRC>"); |
|||
soapRequestData.Append(itemRow["DDTN"] != null ? "<DDTN>" + itemRow["DDTN"].ToString() + "</DDTN>" : "<DDTN>" + "</DDTN>"); |
|||
soapRequestData.Append(itemRow["NTRR_CST"] != null ? "<NTRR_CST>" + itemRow["NTRR_CST"].ToString() + "</NTRR_CST>" : "<NTRR_CST>" + "</NTRR_CST>"); |
|||
soapRequestData.Append(itemRow["VEHS_OPRT_CST"] != null ? "<VEHS_OPRT_CST>" + itemRow["VEHS_OPRT_CST"].ToString() + "</VEHS_OPRT_CST>" : "<VEHS_OPRT_CST>" + "</VEHS_OPRT_CST>"); |
|||
soapRequestData.Append(itemRow["SVC_CST"] != null ? "<SVC_CST>" + itemRow["SVC_CST"].ToString() + "</SVC_CST>" : "<SVC_CST>" + "</SVC_CST>"); |
|||
soapRequestData.Append(itemRow["VEHS_RNTL_CST"] != null ? "<VEHS_RNTL_CST>" + itemRow["VEHS_RNTL_CST"].ToString() + "</VEHS_RNTL_CST>" : "<VEHS_RNTL_CST>" + "</VEHS_RNTL_CST>"); |
|||
soapRequestData.Append(itemRow["OFC_RNTL_CST"] != null ? "<OFC_RNTL_CST>" + itemRow["OFC_RNTL_CST"].ToString() + "</OFC_RNTL_CST>" : "<OFC_RNTL_CST>" + "</OFC_RNTL_CST>"); |
|||
soapRequestData.Append(itemRow["PRPT_MGMT_CST"] != null ? "<PRPT_MGMT_CST>" + itemRow["PRPT_MGMT_CST"].ToString() + "</PRPT_MGMT_CST>" : "<PRPT_MGMT_CST>" + "</PRPT_MGMT_CST>"); |
|||
soapRequestData.Append(itemRow["WTNELCT_CST"] != null ? "<WTNELCT_CST>" + itemRow["WTNELCT_CST"].ToString() + "</WTNELCT_CST>" : "<WTNELCT_CST>" + "</WTNELCT_CST>"); |
|||
soapRequestData.Append(itemRow["NWK_CST"] != null ? "<NWK_CST>" + itemRow["NWK_CST"].ToString() + "</NWK_CST>" : "<NWK_CST>" + "</NWK_CST>"); |
|||
soapRequestData.Append(itemRow["TELE_CST"] != null ? "<TELE_CST>" + itemRow["TELE_CST"].ToString() + "</TELE_CST>" : "<TELE_CST>" + "</TELE_CST>"); |
|||
soapRequestData.Append(itemRow["MEET_CST"] != null ? "<MEET_CST>" + itemRow["MEET_CST"].ToString() + "</MEET_CST>" : "<MEET_CST>" + "</MEET_CST>"); |
|||
soapRequestData.Append(itemRow["PCL_CST"] != null ? "<PCL_CST>" + itemRow["PCL_CST"].ToString() + "</PCL_CST>" : "<PCL_CST>" + "</PCL_CST>"); |
|||
soapRequestData.Append(itemRow["PNCST"] != null ? "<PNCST>" + itemRow["PNCST"].ToString() + "</PNCST>" : "<PNCST>" + "</PNCST>"); |
|||
soapRequestData.Append(itemRow["CUN_CST"] != null ? "<CUN_CST>" + itemRow["CUN_CST"].ToString() + "</CUN_CST>" : "<CUN_CST>" + "</CUN_CST>"); |
|||
soapRequestData.Append(itemRow["DPRCT_CST"] != null ? "<DPRCT_CST>" + itemRow["DPRCT_CST"].ToString() + "</DPRCT_CST>" : "<DPRCT_CST>" + "</DPRCT_CST>"); |
|||
soapRequestData.Append(itemRow["EDU_CST"] != null ? "<EDU_CST>" + itemRow["EDU_CST"].ToString() + "</EDU_CST>" : "<EDU_CST>" + "</EDU_CST>"); |
|||
soapRequestData.Append(itemRow["RPR_CST"] != null ? "<RPR_CST>" + itemRow["RPR_CST"].ToString() + "</RPR_CST>" : "<RPR_CST>" + "</RPR_CST>"); |
|||
soapRequestData.Append(itemRow["LBPRTT_CST"] != null ? "<LBPRTT_CST>" + itemRow["LBPRTT_CST"].ToString() + "</LBPRTT_CST>" : "<LBPRTT_CST>" + "</LBPRTT_CST>"); |
|||
soapRequestData.Append(itemRow["BZ_PRMT_CST"] != null ? "<BZ_PRMT_CST>" + itemRow["BZ_PRMT_CST"].ToString() + "</BZ_PRMT_CST>" : "<BZ_PRMT_CST>" + "</BZ_PRMT_CST>"); |
|||
soapRequestData.Append(itemRow["TEST_CST"] != null ? "<TEST_CST>" + itemRow["TEST_CST"].ToString() + "</TEST_CST>" : "<TEST_CST>" + "</TEST_CST>"); |
|||
soapRequestData.Append(itemRow["BK_CST"] != null ? "<BK_CST>" + itemRow["BK_CST"].ToString() + "</BK_CST>" : "<BK_CST>" + "</BK_CST>"); |
|||
soapRequestData.Append(itemRow["RCRT_CST"] != null ? "<RCRT_CST>" + itemRow["RCRT_CST"].ToString() + "</RCRT_CST>" : "<RCRT_CST>" + "</RCRT_CST>"); |
|||
soapRequestData.Append(itemRow["XBT_CST"] != null ? "<XBT_CST>" + itemRow["XBT_CST"].ToString() + "</XBT_CST>" : "<XBT_CST>" + "</XBT_CST>"); |
|||
soapRequestData.Append(itemRow["RSNB_LOS"] != null ? "<RSNB_LOS>" + itemRow["RSNB_LOS"].ToString() + "</RSNB_LOS>" : "<RSNB_LOS>" + "</RSNB_LOS>"); |
|||
soapRequestData.Append("</MGMT_CST>"); |
|||
//原循环部分 end
|
|||
} |
|||
soapRequestData.Append("</yerp:YERP_006_OA1_MT>"); |
|||
soapRequestData.Append("</soapenv:Body>"); |
|||
soapRequestData.Append("</soapenv:Envelope>"); |
|||
string postData = soapRequestData.ToString(); |
|||
log.Info("YERP_006 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_006_OA1_SI&interfaceNamespace=http://skch.com/YERP_006_MATN_COST"; |
|||
rop.RequestSAP(rop.Url, 10000, postData, "IF_YERP", "Xtxc355860", out statusCode, out resultContent); |
|||
|
|||
log.Info("YERP_006 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,252 @@ |
|||
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_gz : 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.GetConfigString("SysConnectionString_gz"); |
|||
if (string.IsNullOrEmpty(conStr)) |
|||
{ |
|||
log.Info("YERP_006 conStr未找到。"); |
|||
return; |
|||
} |
|||
//<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>
|
|||
|
|||
// 过滤时间为上个月
|
|||
string Date = Dates.ToString("yyyy"); |
|||
string beginMuoth = Dates.AddMonths(-1).ToString("MM"); |
|||
string endMuoth = Dates.ToString("MM"); |
|||
var beginPeriod = "200001";//Date + beginMuoth
|
|||
var endPeriod = "206001";//Date + endMuoth
|
|||
string sqls = @"
|
|||
begin transaction |
|||
|
|||
exec GL_Ledger @tblname=N'cwfymxz',@KmCode=N'5603',@beginPeriod='{0}',@endPeriod='{1}',@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,a.iyear YYYY,imonth MM,iday DD,csign_no SPTDOC,cDigest SMR,cDCode ODR_ACC,a.md DBTO_AMT,a.mc CRDTO_AMT,tmpme tmpme,b.cbegind_c |
|||
into #test |
|||
from tempdb..cwfymxz a |
|||
join GL_accsum b on a.cCode = b.ccode and a.iyear = b.iyear and b.iperiod=1 |
|||
|
|||
select SPTDOC,YYYY,MM,DD,sum(DBTO_AMT) DBTO_AMT,sum(CRDTO_AMT) CRDTO_AMT,sum(isnull(tmpme,0)) tmpme,cbegind_c |
|||
into #test2 |
|||
from #test a |
|||
where SPTDOC is not null and DD IS NOT NULL |
|||
group by SPTDOC,YYYY,MM,DD,cbegind_c |
|||
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,'' DBTO_CRDTO_DVSN,cbegind_c |
|||
|
|||
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; |
|||
} |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue