-----20 ========================= ---- Begin 日结前数据检查报表调整:2024-01-01调整加工的数据 ----重新修改并调整。 ---- ---- ----=========================== if exists(select * from sysobjects where name='p_rpt_overqry' and xtype='p') drop procedure p_rpt_overqry go CREATE procedure p_rpt_overqry ( @pregncode varchar(1000), @pareacode varchar(1000), @porgcode varchar(1000), @ps_SysUserCode varchar(20) ) as declare @ssql varchar(8000) declare @sregncode varchar(1000) declare @sareacode varchar(1000) declare @sorgcode varchar(1000) declare @sfilt varchar(8000) declare @stmpdate varchar(10) declare @thismonth varchar(6) declare @lastmonth varchar(6) begin --set @sregncode=isnull(@pregncode,'') --set @sareacode=isnull(@pareacode,'') --set @sorgcode=isnull(@porgcode,'') set @sregncode=replace(@pregncode,',',''',''') set @sareacode=replace(@pareacode,',',''',''') set @sorgcode=replace(@porgcode,',',''',''') --set @stmpdate=convert(varchar(10),getdate()-1,120) --set @thismonth=substring(@stmpdate,1,4)+substring(@stmpdate,6,2) ---set @stmpdate=convert(varchar(10),dateadd(month,-1,getdate()),120) --set @lastmonth=substring(@stmpdate,1,4)+substring(@stmpdate,6,2) /* ---2024-01-24 已经通过存储过程生成物理表了,故不需要再次生成 if (isnull(@sregncode,'')='' and isnull(@sareacode,'')='' and isnull(@sorgcode,'')='') begin raiserror('查询参数不允许全部为空',16,1) return(1) End */ Set @sfilt=' where 1=1 ' set @sfilt=@sfilt+' and exists(select * from t_user_org where orgcode=a.orgcode and usercode='''+@ps_SysUserCode+''')' if isNull(@sregncode,'')<>'' set @sfilt=@sfilt+' and exists(select * from t_shop m,t_area n where m.areacode=n.areacode and m.orgcode=a.orgcode and n.uppercode1 in ('''+@sregncode+'''))' if isnull(@sareacode,'')<>'' set @sfilt=@sfilt+' and exists(select * from t_shop where orgcode=a.orgcode and areacode in ('''+@sareacode+'''))' if isnull(@sorgcode,'')<>'' set @sfilt=@sfilt+' and a.orgcode in ('''+@sorgcode+''')' ----2024-04-24 存在BOM商品负库存,同时可能类型=“errtype=4”的负库存数据,取最大的类型为5的数据:max(errtype) set @ssql='select (select Areaname From t_area B,t_shop p where B.areacode=substring(p.areacode,1,2) and p.orgcode =a.orgcode ) as regnname, (select Areaname From t_area B,t_shop p where B.areacode=p.areacode and p.orgcode =a.orgcode ) as Areaname, a.orgcode,(Select OrgName From t_Shop P where A.Orgcode=p.orgcode) as OrgName, (Select overdate From t_shop p where p.orgcode=a.orgcode) as overdate, case errtype when ''0'' then ''本站不存在非油日结数据,请邮件联系全站运维重新上传日结数据!'' when ''1'' then ''本站不存在非油日结数据,请邮件联系全站运维重新上传日结数据!'' when ''2'' then ''流水中有商品不存在,联系总部业务正确维护!'' when ''3'' then ''流水中商品主供应商或门店供应商信息不存在,联系总部业务正确维护!'' when ''4'' then ''存在负库存数据(库存不够扣减),检查到货是否验收?或者临盘调整!'' when ''5'' then ''BOM存在负库存数据,检查到货是否验收或临盘调整!'' when ''6'' then a.plucode+''日流水金额与支付日报金额不一致!'' When ''7'' then a.plucode+''其主供应商或门店供应商信息为空,联系总部业务正确维护!'' when ''8'' then ''流水中有商品没有经营权限,联系总部业务正确维护!'' Else ''其他'' End as r_errtype, case errtype when ''6'' then '''' else a.plucode end as plucode , (Select pluName From t_plu p Where plucode =a.plucode ) as pluname,a.xscount,a.kccount,a.xscount-a.kccount as diffcount from (Select orgcode ,max(errtype) as errtype ,plucode,xscount ,kccount from t_tmpoverqry group by orgcode ,plucode,xscount ,kccount ) a ' Set @ssql= @ssql+@sfilt +' order by a.orgcode,a.plucode ' ---order by d.areacode,c.areacode,a.orgcode,a.plucode --print @ssql ---print ('Insert into t_tmp_Rptqry(QrySQL) Value(''' +@ssql+'''') exec(@ssql) end go -----20 ========================= ----End 日结前数据检查报表调整:2023-12-30 ----,把KaFka的实时流水表 t_int_flow_item 调整为: t_flow_item 。 ----Select * from t_flow_item ---- ----===========================