diff --git a/ICSSoft.FromERP/SK/YERP_006.cs b/ICSSoft.FromERP/SK/YERP_006.cs
index e4628aa..8fd2e43 100644
--- a/ICSSoft.FromERP/SK/YERP_006.cs
+++ b/ICSSoft.FromERP/SK/YERP_006.cs
@@ -147,94 +147,113 @@ namespace ICSSoft.FromERP
var endPeriod = Date + endMuoth;// "202407";//Date + endMuoth;
#region 004上海
- // 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 as SPTDOC_NO,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_006_004查询 sql:" + sqls);
- // DataTable vbs04dt = ICSHelper.ExecuteTable(conStr, sqls);
- // log.Info("YERP_006_004查询 sql结果数量" + vbs04dt.Rows.Count);
+ string sql04s = @"
+ 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 as SPTDOC_NO,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
+ ";
+ sql04s = string.Format(sql04s, beginPeriod, endPeriod);
+ log.Info("YERP_006_004查询 sql:" + sql04s);
+ DataTable vbs04dt = ICSHelper.ExecuteTable(conStr, sql04s);
+ log.Info("YERP_006_004查询 sql结果数量" + vbs04dt.Rows.Count);
+ // 所得税
+ // if exists(select 1 from tempdb..sysobjects with(nolock) where name='tmpuf_63Code' and xtype='u')
+ //drop table tempdb..tmpuf_63Code
+ //select bbank,bcash,bCashItem,bcDefine1,bcDefine10,bcDefine11,bcDefine12,bcDefine13,bcDefine14,bcDefine15
+ //,bcDefine16,bcDefine2,bcDefine3,bcDefine4,bcDefine5,bcDefine6,bcDefine7,bcDefine8,bcDefine9,bclose,bcus
+ //,bd_c,bdept,be,bend,bexchange,bGCJS,bitem,bparacc,bpardiff,bperson,bproperty,br,bReport,bsup,bused
+ //,cass_item,cbook_type,cbook_type_engl,cclass,cclass_engl,cclassany,cclassany_engl,ccode,ccode_engl
+ //,ccode_name,cexch_name,cgather,chelp,cmeasure,cother,cUserDefineType,dbegin,dend,dModifyDate
+ //,igrade,iotherused,itrans,iViewItem,iyear
+ //into tempdb..tmpuf_63Code from code with(nolock) where 1=1 and iyear=2024
+
+ // exec GL_Ledger @tblname=N'tmpuf_63',@KmCode=N'6801',@beginPeriod=202406,@endPeriod=202406,@bVouch=0,@bequal=0,@sum=0,@bMJ=0,@swhere=N'',@sAuth=N'',@ReportID=N'GL13',@ReportType=0,@iUnite=0
+
+ // select iyear,imonth,iday,csign_no,cdigest,cdcode,iprice,cexch_flat,nd_s,md_f,md,nc_s,mc_f,mc,
+ // cfx,ne_s,ipriceavg,me_f,nfrattz,me,cPerson_id,ccus_id,cDept_id,cItem_id,csettle,cn_id,cBill,
+ // ccheck,csup_id,cDefine1,cDefine2,cDefine3,cDefine4,cDefine5,cDefine6,cDefine7,cDefine8,cDefine9,
+ // cDefine10,cDefine11,cDefine12,cDefine13,cDefine14,cDefine15,cDefine16,coutsysname,
+ // inid,ibook,mark,tmpme,tmpme_f,tmpne_s,cexch_name ,bshowexch
+ // from tempdb..tmpuf_63 a
#endregion
string sqls = @"begin transaction
@@ -342,17 +361,35 @@ GROUP BY
SPTDOC,imonth,iday
- select YYYY as Created_Year,MM as Created_Month,YYYY,MM,SMR,DBTO_AMT DBTO
-- ,A.SPTDOC as SPTDOC_NO,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
+ --select YYYY as Created_Year,MM as Created_Month,YYYY,MM,SMR,DBTO_AMT DBTO
+ --from #test5 a left join #test9 b on a.SPTDOC=b.SPTDOC and a.MM=b.imonth and a.DD=b.iday
+ --where SMR ='本月合计'
+ --order by MM
+
+if exists(select 1 from tempdb..sysobjects with(nolock) where name='tmpuf_63Code' and xtype='u')
+drop table tempdb..tmpuf_63Code
+select bbank,bcash,bCashItem,bcDefine1,bcDefine10,bcDefine11,bcDefine12,bcDefine13,bcDefine14,bcDefine15
+,bcDefine16,bcDefine2,bcDefine3,bcDefine4,bcDefine5,bcDefine6,bcDefine7,bcDefine8,bcDefine9,bclose,bcus
+,bd_c,bdept,be,bend,bexchange,bGCJS,bitem,bparacc,bpardiff,bperson,bproperty,br,bReport,bsup,bused
+,cass_item,cbook_type,cbook_type_engl,cclass,cclass_engl,cclassany,cclassany_engl,ccode,ccode_engl
+,ccode_name,cexch_name,cgather,chelp,cmeasure,cother,cUserDefineType,dbegin,dend,dModifyDate
+,igrade,iotherused,itrans,iViewItem,iyear
+into tempdb..tmpuf_63Code from code with(nolock) where 1=1 and iyear={2}
+
+ exec GL_Ledger @tblname=N'tmpuf_63',@KmCode=N'6801',@beginPeriod={3},@endPeriod={4},@bVouch=0,@bequal=0,@sum=0,@bMJ=0,@swhere=N'',@sAuth=N'',@ReportID=N'GL13',@ReportType=0,@iUnite=0
+
+ select A.SPTDOC as SPTDOC_NO,YYYY as Created_Year,MM as Created_Month,YYYY,MM,SMR,DBTO_AMT DBTO,c.tmpme as INCOME_TAX
+ from #test5 a
+ left join #test9 b on a.SPTDOC=b.SPTDOC and a.MM=b.imonth and a.DD=b.iday
+ left join tempdb..tmpuf_63 c on a.YYYY = c.iyear and a.MM = c.imonth and c.cdcode = '应交税费(2221)'
where SMR ='本月合计'
order by MM
rollback transaction
";
- sqls = string.Format(sqls, beginPeriod, endPeriod);
+ sqls = string.Format(sqls, beginPeriod, endPeriod, Date, beginPeriod, endPeriod);
log.Info("YERP_006 sql:" + sqls);
DataTable vbsdt = ICSHelper.ExecuteTable(conStr, sqls);
log.Info("sql结果数量" + vbsdt.Rows.Count);
@@ -366,99 +403,99 @@ rollback transaction
}
#region 004广州
- // string sqlsgz04 = @"
- // 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 as SPTDOC_NO,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
- //";
- // sqlsgz04 = string.Format(sqlsgz04, beginPeriod, endPeriod);
- // log.Info("YERP_006_004查询 sql:" + sqlsgz04);
- // DataTable vbsgz04dt = ICSHelper.ExecuteTable(conStr, sqlsgz04);
- // log.Info("YERP_006_004查询 sql结果数量" + vbsgz04dt.Rows.Count);
+ string sqlsgz04 = @"
+ begin transaction
+
+ exec GL_Ledger @tblname=N'zyywsrmxz',@KmCode=N'5601',@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 as SPTDOC_NO,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
+ ";
+ sqlsgz04 = string.Format(sqlsgz04, beginPeriod, endPeriod);
+ log.Info("YERP_006_004查询 sql:" + sqlsgz04);
+ DataTable vbsgz04dt = ICSHelper.ExecuteTable(conStr, sqlsgz04);
+ log.Info("YERP_006_004查询 sql结果数量" + vbsgz04dt.Rows.Count);
#endregion
-
+ //广州 006
string sqlsgz = @"begin transaction
-exec GL_Ledger @tblname=N'glfymxz',@KmCode=N'6602',@beginPeriod='{0}',@endPeriod='{1}',@bVouch=0,@bequal=1,@sum=0,@bMJ=1,@swhere=N'',@sAuth=N'',@ReportID=N'GL13',@ReportType=0,@iUnite=0
+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
@@ -511,7 +548,7 @@ 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
+where a.iYear=2024 and ( bclose=0 and ( ccode like N'5602%' or ccode_name like N'5602%' or ccode_engl like N'5602%' or chelp like N'5602%' )) and ccode <>'5602' and len(ccode)=6
and b.SPTDOC is null
set @i=@i +1
end
@@ -523,36 +560,36 @@ 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
+SUM(CASE WHEN SBJ_CD = '560201' THEN DBTO_AMT ELSE 0 END) OFC_OPRT_CST,
+SUM(CASE WHEN SBJ_CD = '560202' THEN DBTO_AMT ELSE 0 END) BZTRP_CST,
+SUM(CASE WHEN SBJ_CD = '560203' THEN DBTO_AMT ELSE 0 END) TRSF_CST,
+SUM(CASE WHEN SBJ_CD = '560204' THEN DBTO_AMT ELSE 0 END) BNFT_CST,
+SUM(CASE WHEN SBJ_CD = '560205' THEN DBTO_AMT ELSE 0 END) NTTN_CST,
+SUM(CASE WHEN SBJ_CD = '560206' THEN DBTO_AMT ELSE 0 END) SCLISRC,
+SUM(CASE WHEN SBJ_CD = '560207' THEN DBTO_AMT ELSE 0 END) DDTN,
+SUM(CASE WHEN SBJ_CD = '560208' THEN DBTO_AMT ELSE 0 END) NTRR_CST,
+SUM(CASE WHEN SBJ_CD = '560209' THEN DBTO_AMT ELSE 0 END) VEHS_OPRT_CST,
+SUM(CASE WHEN SBJ_CD = '560210' THEN DBTO_AMT ELSE 0 END) SVC_CST,
+SUM(CASE WHEN SBJ_CD = '560211' THEN DBTO_AMT ELSE 0 END) VEHS_RNTL_CST,
+SUM(CASE WHEN SBJ_CD = '560212' THEN DBTO_AMT ELSE 0 END) OFC_RNTL_CST,
+SUM(CASE WHEN SBJ_CD = '560213' THEN DBTO_AMT ELSE 0 END) PRPT_MGMT_CST,
+SUM(CASE WHEN SBJ_CD = '560214' THEN DBTO_AMT ELSE 0 END) WTNELCT_CST,
+SUM(CASE WHEN SBJ_CD = '560215' THEN DBTO_AMT ELSE 0 END) NWK_CST,
+SUM(CASE WHEN SBJ_CD = '560216' THEN DBTO_AMT ELSE 0 END) TELE_CST,
+SUM(CASE WHEN SBJ_CD = '560217' THEN DBTO_AMT ELSE 0 END) MEET_CST,
+SUM(CASE WHEN SBJ_CD = '560218' THEN DBTO_AMT ELSE 0 END) PCL_CST,
+SUM(CASE WHEN SBJ_CD = '560219' THEN DBTO_AMT ELSE 0 END) PNCST,
+SUM(CASE WHEN SBJ_CD = '560220' THEN DBTO_AMT ELSE 0 END) CUN_CST,
+SUM(CASE WHEN SBJ_CD = '560221' THEN DBTO_AMT ELSE 0 END) DPRCT_CST,
+SUM(CASE WHEN SBJ_CD = '560222' THEN DBTO_AMT ELSE 0 END) EDU_CST,
+SUM(CASE WHEN SBJ_CD = '560223' THEN DBTO_AMT ELSE 0 END) RPR_CST,
+SUM(CASE WHEN SBJ_CD = '560224' THEN DBTO_AMT ELSE 0 END) LBPRTT_CST,
+SUM(CASE WHEN SBJ_CD = '560225' THEN DBTO_AMT ELSE 0 END) BZ_PRMT_CST,
+SUM(CASE WHEN SBJ_CD = '560226' THEN DBTO_AMT ELSE 0 END) TEST_CST,
+SUM(CASE WHEN SBJ_CD = '560227' THEN DBTO_AMT ELSE 0 END) BK_CST,
+SUM(CASE WHEN SBJ_CD = '560228' THEN DBTO_AMT ELSE 0 END) RCRT_CST,
+SUM(CASE WHEN SBJ_CD = '560229' THEN DBTO_AMT ELSE 0 END) XBT_CST,
+SUM(CASE WHEN SBJ_CD = '560230' THEN DBTO_AMT ELSE 0 END) RSNB_LOS
into #test9
FROM
@@ -562,17 +599,35 @@ GROUP BY
- select YYYY as Created_Year,MM as Created_Month,YYYY,MM,SMR,DBTO_AMT DBTO
-- ,A.SPTDOC as SPTDOC_NO,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
+ --select YYYY as Created_Year,MM as Created_Month,YYYY,MM,SMR,DBTO_AMT DBTO
+ --from #test5 a left join #test9 b on a.SPTDOC=b.SPTDOC and a.MM=b.imonth and a.DD=b.iday
+ --where SMR ='本月合计'
+ --order by MM
+
+if exists(select 1 from tempdb..sysobjects with(nolock) where name='tmpuf_63Code' and xtype='u')
+drop table tempdb..tmpuf_63Code
+select bbank,bcash,bCashItem,bcDefine1,bcDefine10,bcDefine11,bcDefine12,bcDefine13,bcDefine14,bcDefine15
+,bcDefine16,bcDefine2,bcDefine3,bcDefine4,bcDefine5,bcDefine6,bcDefine7,bcDefine8,bcDefine9,bclose,bcus
+,bd_c,bdept,be,bend,bexchange,bGCJS,bitem,bparacc,bpardiff,bperson,bproperty,br,bReport,bsup,bused
+,cass_item,cbook_type,cbook_type_engl,cclass,cclass_engl,cclassany,cclassany_engl,ccode,ccode_engl
+,ccode_name,cexch_name,cgather,chelp,cmeasure,cother,cUserDefineType,dbegin,dend,dModifyDate
+,igrade,iotherused,itrans,iViewItem,iyear
+into tempdb..tmpuf_63Code from code with(nolock) where 1=1 and iyear={2}
+
+ exec GL_Ledger @tblname=N'tmpuf_63',@KmCode=N'5801',@beginPeriod={3},@endPeriod={4},@bVouch=0,@bequal=0,@sum=0,@bMJ=0,@swhere=N'',@sAuth=N'',@ReportID=N'GL13',@ReportType=0,@iUnite=0
+
+ select A.SPTDOC as SPTDOC_NO,YYYY as Created_Year,MM as Created_Month,YYYY,MM,SMR,DBTO_AMT DBTO,c.tmpme as INCOME_TAX
+ from #test5 a
+ left join #test9 b on a.SPTDOC=b.SPTDOC and a.MM=b.imonth and a.DD=b.iday
+ left join tempdb..tmpuf_63 c on a.YYYY = c.iyear and a.MM = c.imonth and c.cdcode = '应交税费(2221)'
where SMR ='本月合计'
order by MM
rollback transaction
";
- sqlsgz = string.Format(sqlsgz, beginPeriod, endPeriod);
+ sqlsgz = string.Format(sqlsgz, beginPeriod, endPeriod, Date, beginPeriod, endPeriod);
log.Info("YERP_006_gz sql:" + sqlsgz);
DataTable vbsdtgz = ICSHelper.ExecuteTable(conStrgz, sqlsgz);
log.Info("YERP_006_gz sql结果数量" + vbsdtgz.Rows.Count);
@@ -601,6 +656,7 @@ rollback transaction
//soapRequestData.Append(itemRow["SPTDOC_NO"] != null ? "" + itemRow["SPTDOC_NO"].ToString() + "" : "" + "");
soapRequestData.Append(itemRow["SMR"] != null ? "" + 100 + "" : "" + "");
soapRequestData.Append(itemRow["DBTO"] != null ? "" + itemRow["DBTO"].ToString() + "" : "" + "");
+ soapRequestData.Append(itemRow["INCOME_TAX"] != null ? "" + itemRow["INCOME_TAX"].ToString() + "" : "" + "");
//soapRequestData.Append(itemRow["CRDTO"] != null ? "" + itemRow["CRDTO"].ToString() + "" : "" + "");
//soapRequestData.Append(itemRow["DBTO_CRDTO_DVSN"] != null ? "" + itemRow["DBTO_CRDTO_DVSN"].ToString() + "" : "" + "");
//soapRequestData.Append(itemRow["BLNC"] != null ? "" + itemRow["BLNC"].ToString() + "" : "" + "");
@@ -636,64 +692,64 @@ rollback transaction
//soapRequestData.Append(itemRow["RSNB_LOS"] != null ? "" + itemRow["RSNB_LOS"].ToString() + "" : "" + "");
#region 004字段
// 根据年月日凭证号关联SMPL_CST
- //if (vbs04dt.Rows.Count > 0 && !string.IsNullOrEmpty(itemRow["SPTDOC_NO"].ToString()))
- //{
- // var SMPL_CST = vbs04dt.Select("YYYY='" + itemRow["YYYY"].ToString() + "' and MM='" + itemRow["MM"].ToString() + "' and DD='" + itemRow["DD"].ToString() + "' and SPTDOC_NO='" + itemRow["SPTDOC_NO"].ToString() + "'");
- // if (SMPL_CST.Length > 0)
- // {
- // var vbs04row = SMPL_CST.FirstOrDefault();
- // soapRequestData.Append(vbs04row["SMPL_CST"] != null ? "" + vbs04row["SMPL_CST"].ToString() + "" : "" + "");
- // var datatemp = new TempDatas
- // {
- // YYYY = itemRow["YYYY"].ToString(),
- // MM = itemRow["MM"].ToString(),
- // DD = itemRow["DD"].ToString(),
- // SPTDOC_NO = itemRow["SPTDOC_NO"].ToString(),
- // };
- // datarows.Add(datatemp);
- // }
- //}
+ if (vbs04dt.Rows.Count > 0 && !string.IsNullOrEmpty(itemRow["SPTDOC_NO"].ToString()))
+ {
+ var SMPL_CST = vbs04dt.Select("YYYY='" + itemRow["YYYY"].ToString() + "' and MM='" + itemRow["MM"].ToString() + "' and DD='" + itemRow["DD"].ToString() + "' and SPTDOC_NO='" + itemRow["SPTDOC_NO"].ToString() + "'");
+ if (SMPL_CST.Length > 0)
+ {
+ var vbs04row = SMPL_CST.FirstOrDefault();
+ soapRequestData.Append(vbs04row["SMPL_CST"] != null ? "" + vbs04row["SMPL_CST"].ToString() + "" : "" + "");
+ var datatemp = new TempDatas
+ {
+ YYYY = itemRow["YYYY"].ToString(),
+ MM = itemRow["MM"].ToString(),
+ DD = itemRow["DD"].ToString(),
+ SPTDOC_NO = itemRow["SPTDOC_NO"].ToString(),
+ };
+ datarows.Add(datatemp);
+ }
+ }
#endregion
soapRequestData.Append("");
//原循环部分 end
itemIndex++;
}
#region 004
- //log.Info("原本006数据已录入" + soapRequestData.Length + "条。");
- //log.Info("datarows关联到" + datarows.Count + "条。");
- //// 若有未关联的数据,拼接在数据后面
- //if (vbs04dt.Rows.Count > 0)
- //{
- // foreach (DataRow item in vbs04dt.Rows)
- // {
- // if (datarows.Count > 0)
- // {
- // var exists = datarows.Any(q => q.YYYY == item["YYYY"].ToString() && q.MM == item["MM"].ToString() && q.DD == item["DD"].ToString() && q.SPTDOC_NO == item["SPTDOC_NO"].ToString());
- // log.Info("有关联数据" + datarows.Count + "条,过滤后exists结果为" + exists + "。");
- // if (!exists)
- // {
- // soapRequestData.Append("");
- // soapRequestData.Append(item["YYYY"] != null ? "" + item["YYYY"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["MM"] != null ? "" + item["MM"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["DD"] != null ? "" + item["DD"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["SPTDOC_NO"] != null ? "" + item["SPTDOC_NO"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["SMPL_CST"] != null ? "" + item["SMPL_CST"].ToString() + "" : "" + "");
- // soapRequestData.Append("");
- // }
- // }
- // else
- // {
- // soapRequestData.Append("");
- // soapRequestData.Append(item["YYYY"] != null ? "" + item["YYYY"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["MM"] != null ? "" + item["MM"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["DD"] != null ? "" + item["DD"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["SPTDOC_NO"] != null ? "" + item["SPTDOC_NO"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["SMPL_CST"] != null ? "" + item["SMPL_CST"].ToString() + "" : "" + "");
- // soapRequestData.Append("");
- // }
- // itemIndex++;
- // }
- //}
+ log.Info("原本006数据已录入" + soapRequestData.Length + "条。");
+ log.Info("datarows关联到" + datarows.Count + "条。");
+ // 若有未关联的数据,拼接在数据后面
+ if (vbs04dt.Rows.Count > 0)
+ {
+ foreach (DataRow item in vbs04dt.Rows)
+ {
+ if (datarows.Count > 0)
+ {
+ var exists = datarows.Any(q => q.YYYY == item["YYYY"].ToString() && q.MM == item["MM"].ToString() && q.DD == item["DD"].ToString() && q.SPTDOC_NO == item["SPTDOC_NO"].ToString());
+ log.Info("有关联数据" + datarows.Count + "条,过滤后exists结果为" + exists + "。");
+ if (!exists)
+ {
+ soapRequestData.Append("");
+ soapRequestData.Append(item["YYYY"] != null ? "" + item["YYYY"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["MM"] != null ? "" + item["MM"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["DD"] != null ? "" + item["DD"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["SPTDOC_NO"] != null ? "" + item["SPTDOC_NO"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["SMPL_CST"] != null ? "" + item["SMPL_CST"].ToString() + "" : "" + "");
+ soapRequestData.Append("");
+ }
+ }
+ else
+ {
+ soapRequestData.Append("");
+ soapRequestData.Append(item["YYYY"] != null ? "" + item["YYYY"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["MM"] != null ? "" + item["MM"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["DD"] != null ? "" + item["DD"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["SPTDOC_NO"] != null ? "" + item["SPTDOC_NO"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["SMPL_CST"] != null ? "" + item["SMPL_CST"].ToString() + "" : "" + "");
+ soapRequestData.Append("");
+ }
+ itemIndex++;
+ }
+ }
#endregion
log.Info("006上海数据录入" + itemIndex + "条。");
}
@@ -710,6 +766,7 @@ rollback transaction
//soapRequestData.Append(itemRow["SPTDOC_NO"] != null ? "" + itemRow["SPTDOC_NO"].ToString() + "" : "" + "");
soapRequestData.Append(itemRow["SMR"] != null ? "" + 200 + "" : "" + "");
soapRequestData.Append(itemRow["DBTO"] != null ? "" + itemRow["DBTO"].ToString() + "" : "" + "");
+ soapRequestData.Append(itemRow["INCOME_TAX"] != null ? "" + itemRow["INCOME_TAX"].ToString() + "" : "" + "");
//soapRequestData.Append(itemRow["CRDTO"] != null ? "" + itemRow["CRDTO"].ToString() + "" : "" + "");
//soapRequestData.Append(itemRow["DBTO_CRDTO_DVSN"] != null ? "" + itemRow["DBTO_CRDTO_DVSN"].ToString() + "" : "" + "");
//soapRequestData.Append(itemRow["BLNC"] != null ? "" + itemRow["BLNC"].ToString() + "" : "" + "");
@@ -744,24 +801,24 @@ rollback transaction
//soapRequestData.Append(itemRow["XBT_CST"] != null ? "" + itemRow["XBT_CST"].ToString() + "" : "" + "");
//soapRequestData.Append(itemRow["RSNB_LOS"] != null ? "" + itemRow["RSNB_LOS"].ToString() + "" : "" + "");
#region 004字段
- //// 根据年月日凭证号关联SMPL_CST
- //if (vbsgz04dt.Rows.Count > 0 && !string.IsNullOrEmpty(itemRow["SPTDOC_NO"].ToString()))
- //{
- // var SMPL_CST = vbsgz04dt.Select("YYYY='" + itemRow["YYYY"].ToString() + "' and MM='" + itemRow["MM"].ToString() + "' and DD='" + itemRow["DD"].ToString() + "' and SPTDOC_NO='" + itemRow["SPTDOC_NO"].ToString() + "'");
- // if (SMPL_CST.Length > 0)
- // {
- // var vbs04row = SMPL_CST.FirstOrDefault();
- // soapRequestData.Append(vbs04row["SMPL_CST"] != null ? "" + vbs04row["SMPL_CST"].ToString() + "" : "" + "");
- // var datatemp = new TempDatas
- // {
- // YYYY = itemRow["YYYY"].ToString(),
- // MM = itemRow["MM"].ToString(),
- // DD = itemRow["DD"].ToString(),
- // SPTDOC_NO = itemRow["SPTDOC_NO"].ToString(),
- // };
- // datarows.Add(datatemp);
- // }
- //}
+ // 根据年月日凭证号关联SMPL_CST
+ if (vbsgz04dt.Rows.Count > 0 && !string.IsNullOrEmpty(itemRow["SPTDOC_NO"].ToString()))
+ {
+ var SMPL_CST = vbsgz04dt.Select("YYYY='" + itemRow["YYYY"].ToString() + "' and MM='" + itemRow["MM"].ToString() + "' and DD='" + itemRow["DD"].ToString() + "' and SPTDOC_NO='" + itemRow["SPTDOC_NO"].ToString() + "'");
+ if (SMPL_CST.Length > 0)
+ {
+ var vbs04row = SMPL_CST.FirstOrDefault();
+ soapRequestData.Append(vbs04row["SMPL_CST"] != null ? "" + vbs04row["SMPL_CST"].ToString() + "" : "" + "");
+ var datatemp = new TempDatas
+ {
+ YYYY = itemRow["YYYY"].ToString(),
+ MM = itemRow["MM"].ToString(),
+ DD = itemRow["DD"].ToString(),
+ SPTDOC_NO = itemRow["SPTDOC_NO"].ToString(),
+ };
+ datarows.Add(datatemp);
+ }
+ }
#endregion
soapRequestData.Append("");
//原循环部分 end
@@ -771,39 +828,39 @@ rollback transaction
log.Info("datarows关联到" + datarows.Count + "条。");
#region 004广州
// 若有未关联的数据,拼接在数据后面
- //if (vbsgz04dt.Rows.Count > 0)
- //{
- // foreach (DataRow item in vbsgz04dt.Rows)
- // {
- // if (datarows.Count > 0)
- // {
- // var exists = datarows.Any(q => q.YYYY == item["YYYY"].ToString() && q.MM == item["MM"].ToString() && q.DD == item["DD"].ToString() && q.SPTDOC_NO == item["SPTDOC_NO"].ToString());
- // log.Info("有关联数据" + datarows.Count + "条,过滤后exists结果为" + exists + "。");
- // if (!exists)
- // {
- // soapRequestData.Append("");
- // soapRequestData.Append(item["YYYY"] != null ? "" + item["YYYY"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["MM"] != null ? "" + item["MM"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["DD"] != null ? "" + item["DD"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["SPTDOC_NO"] != null ? "" + item["SPTDOC_NO"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["SMPL_CST"] != null ? "" + item["SMPL_CST"].ToString() + "" : "" + "");
- // soapRequestData.Append("");
- // }
- // }
- // else
- // {
- // soapRequestData.Append("");
- // soapRequestData.Append(item["YYYY"] != null ? "" + item["YYYY"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["MM"] != null ? "" + item["MM"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["DD"] != null ? "" + item["DD"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["SPTDOC_NO"] != null ? "" + item["SPTDOC_NO"].ToString() + "" : "" + "");
- // soapRequestData.Append(item["SMPL_CST"] != null ? "" + item["SMPL_CST"].ToString() + "" : "" + "");
- // soapRequestData.Append("");
- // }
- // itemgzIndex++;
- // }
- //}
- //log.Info("006广州数据录入" + itemgzIndex + "条。");
+ if (vbsgz04dt.Rows.Count > 0)
+ {
+ foreach (DataRow item in vbsgz04dt.Rows)
+ {
+ if (datarows.Count > 0)
+ {
+ var exists = datarows.Any(q => q.YYYY == item["YYYY"].ToString() && q.MM == item["MM"].ToString() && q.DD == item["DD"].ToString() && q.SPTDOC_NO == item["SPTDOC_NO"].ToString());
+ log.Info("有关联数据" + datarows.Count + "条,过滤后exists结果为" + exists + "。");
+ if (!exists)
+ {
+ soapRequestData.Append("");
+ soapRequestData.Append(item["YYYY"] != null ? "" + item["YYYY"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["MM"] != null ? "" + item["MM"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["DD"] != null ? "" + item["DD"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["SPTDOC_NO"] != null ? "" + item["SPTDOC_NO"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["SMPL_CST"] != null ? "" + item["SMPL_CST"].ToString() + "" : "" + "");
+ soapRequestData.Append("");
+ }
+ }
+ else
+ {
+ soapRequestData.Append("");
+ soapRequestData.Append(item["YYYY"] != null ? "" + item["YYYY"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["MM"] != null ? "" + item["MM"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["DD"] != null ? "" + item["DD"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["SPTDOC_NO"] != null ? "" + item["SPTDOC_NO"].ToString() + "" : "" + "");
+ soapRequestData.Append(item["SMPL_CST"] != null ? "" + item["SMPL_CST"].ToString() + "" : "" + "");
+ soapRequestData.Append("");
+ }
+ itemgzIndex++;
+ }
+ }
+ log.Info("006广州数据录入" + itemgzIndex + "条。");
#endregion
}
log.Info("006最终数据录入" + itemgzIndex + itemIndex + "条。");
diff --git a/ICSSoft.FromERP/SK/YERP_007.cs b/ICSSoft.FromERP/SK/YERP_007.cs
index a6f9a4b..d237961 100644
--- a/ICSSoft.FromERP/SK/YERP_007.cs
+++ b/ICSSoft.FromERP/SK/YERP_007.cs
@@ -526,7 +526,7 @@ namespace ICSSoft.FromERP
string sqlyywsr_gz = @"
begin transaction
- exec GL_Ledger @tblname=N'cwfymxz',@KmCode=N'6301',@beginPeriod='{0}',@endPeriod='{1}',@bVouch=0,@bequal=1,@sum=0,@bMJ=1,@swhere=N'',@sAuth=N'',@ReportID=N'GL13',@ReportType=0,@iUnite=0
+ exec GL_Ledger @tblname=N'cwfymxz',@KmCode=N'5301',@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
@@ -629,7 +629,7 @@ namespace ICSSoft.FromERP
string sqlyywzc_gz = @"begin transaction
- exec GL_Ledger @tblname=N'cwfymxz',@KmCode=N'6711',@beginPeriod='{0}',@endPeriod='{1}',@bVouch=0,@bequal=1,@sum=0,@bMJ=1,@swhere=N'',@sAuth=N'',@ReportID=N'GL13',@ReportType=0,@iUnite=0
+ exec GL_Ledger @tblname=N'cwfymxz',@KmCode=N'5711',@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