You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

362 lines
16 KiB

1 year ago
--<EFBFBD>ս<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if exists (select name from sysobjects where name='p_sys_day_over_plugin' and xtype='p')
drop procedure p_sys_day_over_plugin
go
create procedure p_sys_day_over_plugin
(
@orgcode varchar(10),
@accdate varchar(10),
@acctimes int,
@usercode varchar(10),
@vipdbname varchar(20),
@message varchar(200) out
)
as
declare @psmsg varchar(200)
begin
declare @curedition varchar(1)
declare @finaltype varchar(1)
declare @irtnresult int
declare @srtnmsg varchar(200)
declare @sautopdaccount varchar(1)
declare @ssql varchar(2000)
set @sautopdaccount = isnull(@sautopdaccount,'0')
set @finaltype = null
--sap<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
exec @irtnresult = p_int_gen_flow_item @orgcode, @accdate, @srtnmsg out
if @irtnresult <> 1
begin
insert into t_over_error (orgcode, overdate, overtime, errreason)
values (@orgcode, @accdate, convert(varchar(10), getdate(), 24), @srtnmsg)
end
--sap<EFBFBD><EFBFBD><EFBFBD>۳ɱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
exec @irtnresult = p_int_gen_flow_chg @orgcode, @accdate, @srtnmsg out
if @irtnresult <> 1
begin
insert into t_over_error (orgcode, overdate, overtime, errreason)
values (@orgcode, @accdate, convert(varchar(10), getdate(), 24), @srtnmsg)
end
--sap֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
exec @irtnresult = p_int_gen_flow_pay @orgcode, @accdate, @srtnmsg out
if @irtnresult <> 1
begin
insert into t_over_error (orgcode, overdate, overtime, errreason)
values (@orgcode, @accdate, convert(varchar(10), getdate(), 24), @srtnmsg)
end
--sap<EFBFBD>ֽ<EFBFBD><EFBFBD>ɴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
exec @irtnresult = p_int_gen_flow_pay_cash @orgcode, @accdate, @srtnmsg out
if @irtnresult <> 1
begin
insert into t_over_error (orgcode, overdate, overtime, errreason)
values (@orgcode, @accdate, convert(varchar(10), getdate(), 24), @srtnmsg)
end
set @message = ''
return (1)
end
go
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if exists (select name from sysobjects where name='p_int_gen_flow_item' and xtype='p')
drop procedure p_int_gen_flow_item
go
create procedure p_int_gen_flow_item
(
@psorgcode varchar(10),
@psaccdate varchar(10),
@psmsg varchar(2000) out
)
as
begin
declare @tablename varchar(40)
declare @where varchar(2000)
declare @sql varchar(5000)
declare @createdate varchar(20)
set @tablename = 't_plusale_'+substring(@psaccdate,1,4)+substring(@psaccdate,6,2)
set @where = ''
set @createdate = convert(varchar(20),getdate(),120)
if not exists(select * from sysobjects where name=@tablename)
begin
set @psmsg = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD>'+@tablename
return(-1)
end
if @psorgcode <> '' and @psorgcode is not null and @psorgcode <> '*'
begin
set @where = ' and sale.OrgCode = ''' + @psorgcode + ''''
end
set @sql = 'insert into t_int_sap_drysalesinfo' +
' (CREATEDATE,IFTYPE,BUKRS,WERKS,ZSIGN,PRCTR,ZYWDAT,ZTYPE,ZCXLX,ZJYFS,' +
' VVTYP,MATNR,MENGE,MEINS,PRICE,SKTAK,SKTBT,TMWSTS,GTTAX,WAERS,ZTOLAMT,' +
' ZTSDAT,ZGZDAT,ZFNAME,ZUNFLG,ZYZLX,MWSKZ)' +
'select ''' + @createdate + ''' as CREATEDATE,''F01'' as IFTYPE,FinaCode as BUKRS,OrgCode as WERKS,''1'' as ZSIGN,''P''+FinaCode+''1''+OrgCode as PRCTR,replace(AccDate,''-'','''') as ZYWDAT,''F01'' as ZTYPE,''Z30'' as ZCXLX,''Z01'' as ZJYFS,' +
' '''' as VVTYP,ClsCode as MATNR,Counts as MENGE,case ClsCode when ''2018'' then ''L'' else ''EA'' end as MEINS,Total as PRICE,Total as SKTAK,0 as SKTBT,round(Total-Total/(1+STaxRate/100.00),2) as TMWSTS,0 as GTTAX,''CNY'' as WAERS,0 as ZTOLAMT,' +
' convert(varchar(8),getdate(),112) as ZTSDAT,replace(AccDate,''-'','''') as ZGZDAT,'''' as ZFNAME,case when Counts < 0 then ''Y'' else '''' end as ZUNFLG,case OrgType when ''1'' then ''DO'' else ''COCO'' end as ZYZLX,' +
' case STaxRate when 0 then ''X0'' when 17 then ''X1'' when 13 then ''X2'' when 2 then ''X3'' when 6 then ''X4'' when 11 then ''X5'' when 16 then ''X7'' when 10 then ''X8'' when 9 then ''X9'' end as MWSKZ' +
' from (' +
' select AccDate,FinaCode,OrgCode,ClsCode,STaxRate,OrgType,sum(Total) as Total,sum(Amount) as Amount,sum(Counts) as Counts' +
' from (' +
' select sale.AccDate,shop.FinaCode,sale.OrgCode,class.UpperCode1 as ClsCode,sale.STaxRate,' +
' isnull((select JyMode from t_supplier where SupCode = sale.SupCode),''0'') as JyMode,' +
' sale.Counts,sale.Total,sale.Amount,shop.OrgType' +
' from ' + @tablename + ' sale, t_shop shop, t_plu plu, t_gclass class' +
' where sale.OrgCode = shop.OrgCode' +
' and sale.PluCode = plu.PluCode' +
' and plu.ClsCode = class.ClsCode' +
' and sale.AccDate = ''' + @psaccdate + '''' + @where +
' ) b' +
' where JyMode = ''0''' +
' group by AccDate,FinaCode,OrgCode,ClsCode,STaxRate,OrgType' +
' ) a' +
' where Amount <> 0 or Counts <> 0'
exec(@sql)
set @sql = 'insert into t_int_sap_drysalesinfo' +
' (CREATEDATE,IFTYPE,BUKRS,WERKS,ZSIGN,PRCTR,ZYWDAT,ZTYPE,ZCXLX,ZJYFS,' +
' VVTYP,MATNR,MENGE,MEINS,PRICE,SKTAK,SKTBT,TMWSTS,GTTAX,WAERS,ZTOLAMT,' +
' ZTSDAT,ZGZDAT,ZFNAME,ZUNFLG,ZYZLX,MWSKZ)' +
'select ''' + @createdate + ''' as CREATEDATE,''F01'' as IFTYPE,FinaCode as BUKRS,OrgCode as WERKS,''1'' as ZSIGN,''P''+FinaCode+''1''+OrgCode as PRCTR,replace(AccDate,''-'','''') as ZYWDAT,''F01'' as ZTYPE,''Z30'' as ZCXLX,''Z03'' as ZJYFS,' +
' '''' as VVTYP,ClsCode as MATNR,Counts as MENGE,case ClsCode when ''2018'' then ''L'' else ''EA'' end as MEINS,Amount as PRICE,Total as SKTAK,DkTotal as SKTBT,round(DkTotal-DkTotal/(1+STaxRate/100.00),2) as TMWSTS,0 as GTTAX,''CNY'' as WAERS,0 as ZTOLAMT,' +
' convert(varchar(8),getdate(),112) as ZTSDAT,replace(AccDate,''-'','''') as ZGZDAT,'''' as ZFNAME,case when Counts < 0 then ''Y'' else '''' end as ZUNFLG,case OrgType when ''1'' then ''DO'' else ''COCO'' end as ZYZLX,' +
' case STaxRate when 0 then ''X0'' when 17 then ''X1'' when 13 then ''X2'' when 2 then ''X3'' when 6 then ''X4'' when 11 then ''X5'' when 16 then ''X7'' when 10 then ''X8'' when 9 then ''X9'' end as MWSKZ' +
' from (' +
' select AccDate,FinaCode,OrgCode,ClsCode,STaxRate,OrgType,sum(Total) as Total,sum(Amount) as Amount,sum(Total-Cost) as DkTotal,sum(Counts) as Counts' +
' from (' +
' select sale.AccDate,shop.FinaCode,sale.OrgCode,class.UpperCode1 as ClsCode,sale.STaxRate,' +
' isnull((select JyMode from t_supplier where SupCode = sale.SupCode),''0'') as JyMode,' +
' sale.Counts,sale.Cost,sale.Total,sale.Amount,shop.OrgType' +
' from ' + @tablename + ' sale, t_shop shop, t_plu plu, t_gclass class' +
' where sale.OrgCode = shop.OrgCode' +
' and sale.PluCode = plu.PluCode' +
' and plu.ClsCode = class.ClsCode' +
' and sale.AccDate = ''' + @psaccdate + '''' + @where +
' ) b' +
' where JyMode = ''2''' +
' group by AccDate,FinaCode,OrgCode,ClsCode,STaxRate,OrgType' +
' ) a' +
' where Amount <> 0 or Counts <> 0'
exec(@sql)
if @@error <>0
begin
set @psmsg = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸʧ<EFBFBD><EFBFBD>'
return(-1)
end
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD>ţ<EFBFBD>3λҵ<EFBFBD><EFBFBD>ǰ׺+6λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>+6<EFBFBD><EFBFBD>ˮ<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>
update t_int_sap_drysalesinfo
set DOCNO = 'XSD' + ZYWDAT + convert(varchar(10),SERIALNO)
where IFTYPE = 'F01' and ZJYFS in ('Z01','Z03') and DOCNO is null
set @psmsg = ''
return (1)
end
go
--<EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD>
if exists (select name from sysobjects where name='p_int_gen_flow_chg' and xtype='p')
drop procedure p_int_gen_flow_chg
go
create procedure p_int_gen_flow_chg
(
@psorgcode varchar(10),
@psaccdate varchar(10),
@psmsg varchar(2000) out
)
as
begin
declare @tablename varchar(40)
declare @where varchar(2000)
declare @sql varchar(2000)
declare @createdate varchar(20)
set @tablename = 't_plusale_'+substring(@psaccdate,1,4)+substring(@psaccdate,6,2)
set @where = ''
set @createdate = convert(varchar(20),getdate(),120)
if not exists(select * from sysobjects where name=@tablename)
begin
set @psmsg = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD>'+@tablename
return(-1)
end
if @psorgcode <> '' and @psorgcode is not null and @psorgcode <> '*'
begin
set @where = ' and sale.OrgCode = ''' + @psorgcode + ''''
end
set @sql = 'insert into t_int_sap_inventorychginfo' +
' (CREATEDATE,IFTYPE,BUKRS,ZSIGN,WERKS,PRCTR,ZYWDAT,ZTYPE,MATNR,ZJYFS,' +
' SLTWR,WEARS,MENGE,DWERT,MEINS,ZTSDAT,ZGZDAT,ZCSBS,ZYZLX,UNFLG)' +
'select ''' + @createdate + ''' as CREATEDATE,''F11'' as IFTYPE,FinaCode as BUKRS,''1'' as ZSIGN,OrgCode as WERKS,''P''+FinaCode+''1''+OrgCode as PRCTR,replace(AccDate,''-'','''') as ZYWDAT,''F11'' as ZTYPE,ClsCode as MATNR,case JyMode when ''0'' then ''Z01'' else ''Z03'' end as ZJYFS,' +
' NetCost as SLTWR,''CNY'' as WEARS,Counts as MENGE,0 as DWERT,case ClsCode when ''2018'' then ''L'' else ''EA'' end as MEINS,convert(varchar(8),getdate(),112) as ZTSDAT,replace(AccDate,''-'','''') as ZGZDAT,''X'' as ZCSBS,case OrgType when ''1'' then ''DO'' else ''COCO'' end as ZYZLX,case when Counts < 0 then ''Y'' else '''' end as UNFLG' +
' from (' +
' select AccDate,FinaCode,OrgCode,ClsCode,JyMode,OrgType,sum(NetCost+NetAdjustProfit) as NetCost,sum(Counts) as Counts' +
' from (' +
' select sale.AccDate,shop.FinaCode,sale.OrgCode,class.UpperCode1 as ClsCode,' +
' isnull((select JyMode from t_supplier where SupCode = sale.SupCode),''0'') as JyMode,' +
' sale.NetCost,sale.NetAdjustProfit,sale.Counts,shop.OrgType' +
' from ' + @tablename + ' sale, t_shop shop, t_plu plu, t_gclass class' +
' where sale.OrgCode = shop.OrgCode' +
' and sale.PluCode = plu.PluCode' +
' and plu.ClsCode = class.ClsCode' +
' and sale.AccDate = ''' + @psaccdate + '''' + @where +
' ) b' +
' where JyMode = ''0''' +
' group by AccDate,FinaCode,OrgCode,ClsCode,OrgType,JyMode' +
' ) a' +
' where NetCost <> 0 or Counts <> 0'
exec(@sql)
if @@error <>0
begin
set @psmsg = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۳ɱ<EFBFBD>ʧ<EFBFBD><EFBFBD>'
return(-1)
end
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD>ţ<EFBFBD>3λҵ<EFBFBD><EFBFBD>ǰ׺+6λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>+6<EFBFBD><EFBFBD>ˮ<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>
update t_int_sap_inventorychginfo
set DOCNO = 'XSC' + ZYWDAT + convert(varchar(10),SERIALNO)
where IFTYPE = 'F11' and ZJYFS in ('Z01','Z03') and DOCNO is null
set @psmsg = ''
return (1)
end
go
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>
if exists (select name from sysobjects where name='p_int_gen_flow_pay' and xtype='p')
drop procedure p_int_gen_flow_pay
go
create procedure p_int_gen_flow_pay
(
@psorgcode varchar(10),
@psaccdate varchar(10),
@psmsg varchar(2000) out
)
as
begin
declare @tablename varchar(40)
declare @where varchar(2000)
declare @sql varchar(2000)
declare @createdate varchar(20)
set @tablename = 't_int_flow_pay_deily_'+substring(@psaccdate,1,4)+substring(@psaccdate,6,2)
set @where = ''
set @createdate = convert(varchar(20),getdate(),120)
if not exists(select * from sysobjects where name=@tablename)
begin
set @psmsg = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD>'+@tablename
return(-1)
end
if @psorgcode <> '' and @psorgcode is not null and @psorgcode <> '*'
begin
set @where = ' and shop.OrgCode = ''' + @psorgcode + ''''
end
set @sql = 'insert into t_int_sap_paymentreportinfo' +
' (CREATEDATE,IFTYPE,ZSIGN,ZTSDAT,BUKRS,PRCTR,KUNNR,' +
' SKART,ZYYDAT,WRBTR,WEARS,ZCXBS)' +
'select ''' + @createdate + ''' as CREATEDATE,''Z01'' as IFTYPE,''1'' as ZSIGN,convert(varchar(8),getdate(),112) as ZTSDAT,FinaCode as BUKRS,''P''+FinaCode+''1''+OrgCode as PRCTR,OrgCode as KUNNR,' +
' PayCode,replace(AccDate,''-'','''') as ZYYDAT,Amount as WRBTR,''CNY'' as WEARS,case when Amount < 0 then ''Y'' else '''' end as ZCXBS' +
' from (' +
' select pay.BUSINESS_DATE as AccDate,shop.FinaCode,pay.WERKS as OrgCode,pay.MOP_ID as PayCode,sum(pay.AMOUNT) as Amount' +
' from ' + @tablename + ' pay, t_shop shop' +
' where pay.WERKS = shop.OrgCode' +
' and pay.ITEM_ID like ''20%''' + -- ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
' and pay.BUSINESS_DATE > ''2023-09-15''' +
' and pay.BUSINESS_DATE = ''' + @psaccdate + '''' + @where +
' group by pay.BUSINESS_DATE,shop.FinaCode,pay.WERKS,pay.MOP_ID' +
' ) a' +
' where Amount <> 0'
exec(@sql)
if @@error <>0
begin
set @psmsg = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽʧ<EFBFBD><EFBFBD>'
return(-1)
end
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD>ţ<EFBFBD>3λҵ<EFBFBD><EFBFBD>ǰ׺+6λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>+6<EFBFBD><EFBFBD>ˮ<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>
update t_int_sap_paymentreportinfo
set DOCNO = 'ZFD' + ZTSDAT + convert(varchar(10),SERIALNO)
where IFTYPE = 'Z01' and DOCNO is null
set @psmsg = ''
return (1)
end
go
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
if exists (select name from sysobjects where name='p_int_gen_flow_pay_cash' and xtype='p')
drop procedure p_int_gen_flow_pay_cash
go
create procedure p_int_gen_flow_pay_cash
(
@psorgcode varchar(10),
@psaccdate varchar(10),
@psmsg varchar(2000) out
)
as
begin
declare @tablename varchar(40)
declare @where varchar(2000)
declare @sql varchar(2000)
declare @createdate varchar(20)
set @tablename = 't_int_flow_pay_deily_'+substring(@psaccdate,1,4)+substring(@psaccdate,6,2)
set @where = ''
set @createdate = convert(varchar(20),getdate(),120)
if not exists(select * from sysobjects where name=@tablename)
begin
set @psmsg = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD>'+@tablename
return(-1)
end
if @psorgcode <> '' and @psorgcode is not null and @psorgcode <> '*'
begin
set @where = ' and shop.OrgCode = ''' + @psorgcode + ''''
end
set @sql = 'insert into t_int_sap_cashpaymentinfo' +
' (CREATEDATE,IFTYPE,ZSIGN,ZTSDAT,BUKRS,PRCTR,KUNNR,SKART,' +
' ZYRDAT,JCRQ,WRBTR,JCYYK,SYBTR,CDYSK,JKDOC,ZGZDAT,WAERS,ZCXBS)' +
'select ''' + @createdate + ''' as CREATEDATE,''Z02'' as IFTYPE,''1'' as ZSIGN,convert(varchar(8),getdate(),112) as ZTSDAT,FinaCode as BUKRS,''P''+FinaCode+''1''+OrgCode as PRCTR,OrgCode as KUNNR,''1000001'' as SKART,' +
' replace(AccDate,''-'','''') as ZYRDAT,replace(AccDate,''-'','''') as JCRQ,Amount as WRBTR,Amount as JCYYK,0 as SYBTR,0 as CDYSK,'''' as JKDOC,replace(AccDate,''-'','''') as ZGZDAT,''CNY'' as WAERS,case when Amount < 0 then ''Y'' else '''' end as ZCXBS' +
' from (' +
' select pay.BUSINESS_DATE as AccDate,shop.FinaCode,pay.WERKS as OrgCode,sum(pay.AMOUNT) as Amount' +
' from ' + @tablename + ' pay, t_shop shop' +
' where pay.WERKS = shop.OrgCode' +
' and pay.MOP_ID = ''40''' + -- 40-<2D>ֽ𣬸<D6BD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BOSϵͳֱ<CDB3><D6B1><EFBFBD>·<EFBFBD>
' and pay.ITEM_ID like ''20%''' + -- ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
' and pay.BUSINESS_DATE > ''2023-09-15''' +
' and pay.BUSINESS_DATE = ''' + @psaccdate + '''' + @where +
' group by pay.BUSINESS_DATE,shop.FinaCode,pay.WERKS' +
' ) a' +
' where Amount <> 0'
exec(@sql)
if @@error <>0
begin
set @psmsg = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>֧<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>'
return(-1)
end
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD>ţ<EFBFBD>3λҵ<EFBFBD><EFBFBD>ǰ׺+6λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>+6<EFBFBD><EFBFBD>ˮ<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>
update t_int_sap_cashpaymentinfo
set DOCNO = 'ZFX' + ZTSDAT + convert(varchar(10),SERIALNO)
where IFTYPE = 'Z02' and DOCNO is null
set @psmsg = ''
return (1)
end
go