系统中有前台服务器和后台服务器,前台的销售数据是直接传到前台服务器的,而后台是通过作业定时从前台获取销售记录的。分析原因:
1 后台定时执行没有执行,由于数据库的代理服务没有启动或者人为的将作业停了,导致后台定时执行没有执行;处理办法,启动作业,开启数据库代理的服务
2 销售拆分问题:销售数据传到后台后,系统会进行拆分,拆分完成后,才会在相关报表中体现,才会真正算销售。销售拆分出错是绝大多少销售没有传到后台的原因。导致这样的情况一般有下面几个情况 1、有人修改tb_trans_status,导致记录已拆分记录错误 处理办法:修改 tb_trans_status中销售拆分的id,可以找最大tb_o_sg.c_identity;2、前台硬件故障,销售重复传送,特征:tb_o_sale.c_guid重复处理办法:删除重复的c_guid;3、商品后台不存在,这个一般由于后台删除商品后,没有及时传到前台,前台正好做了销售,处理办法:删除改流水,用正确的商品编码销售;4、商品在一个门店存在2个部门,销售拆分时不知道是哪个部门算哪个部门的销售,处理办法:删除错误的部门。
辅助查询语句:
/*tb_o_sale.c_guid重复*/
select * from tb_o_sale
where c_identity>(select isnull(c_id,0) from tb_trans_status where c_proc='销售分拆')
and exists (select * from tb_o_sg (nolock) where tb_o_sale.c_guid=tb_o_sg.c_guid)
/*一个商品在一个门店存在2个部门*/
select c_store_id,c_gcode,COUNT(*) as c_count
from(
select tb_o_sale.c_gcode,tb_gdsstore.c_store_id,tb_gdsstore.c_adno
from tb_o_sale(nolock),tb_gdsstore(nolock)
where c_identity>(select isnull(c_id,0) from tb_trans_status where c_proc='销售分拆')
and tb_o_sale.c_gcode=tb_gdsstore.c_gcode
group by tb_o_sale.c_gcode,tb_gdsstore.c_store_id,tb_gdsstore.c_adno
)a
group by c_store_id,c_gcode
having COUNT(*)>1
/*商品编码后台不存在*/
select * from tb_o_sale
where c_identity>(select isnull(c_id,0) from tb_trans_status where c_proc='销售分拆')
and not exists (select * from tb_gds (nolock) where tb_o_sale.c_gcode=tb_gds.c_gcode)
and c_flag='G'
还有一种:
select c_guid from tb_o_sale
where c_identity>(select isnull(c_id,0) from tb_trans_status where c_proc='销售分拆')
group by c_guid
having count(*)>1
还有一种情况,没有可用的资源了,比方磁盘空间或者内存设置过低 或者本身服务器内存就比较小
导致服务被终止,传输无法运行,我这出现过类似的问题
处理方法:
1 先将数据做好备份
2 删除重复数据
3 观察作业是否成功
以/*tb_o_sale.c_guid重复*/为例:
第一步:
select * into tb_o_sale_20110815
from tb_o_sale
where c_identity>(select isnull(c_id,0) from tb_trans_status where c_proc='销售分拆')
and exists (select * from tb_o_sg (nolock) where tb_o_sale.c_guid=tb_o_sg.c_guid)
第二步:
delete from tb_o_sale
where c_identity>(select isnull(c_id,0) from tb_trans_status where c_proc='销售分拆')
and exists (select * from tb_o_sg (nolock) where tb_o_sale.c_guid=tb_o_sg.c_guid)
第三步:
查看作业是否成功,实时销售监察是否正确
如果不想让错误数据影响当天销售,可以建立作业,将错误数据做好备份,让剩余数据正常拆分,建议一天晚上执行一次
if not exists(select * from sysobjects where name='tb_o_sale_err')
begin
CREATE TABLE [dbo].[tb_o_sale_err](
[c_guid] [varchar](36) NULL,
[c_identity] [int] NOT NULL,
[c_pos_identity] [int] NULL,
[c_id] [int] NOT NULL,
[c_computer_id] [int] NOT NULL,
[c_datetime] [datetime] NOT NULL,
[c_cashier] [varchar](10) NOT NULL,
[c_flag] [char](1) NULL,
[c_cardno] [varchar](20) NULL,
[c_adno] [varchar](10) NULL,
[c_gcode] [varchar](13) NOT NULL,
[c_subcode] [varchar](10) NOT NULL,
[c_pt_cost] [money] NULL,
[c_price] [money] NULL,
[c_price_pro] [money] NULL,
[c_price_disc] [money] NULL,
[c_qtty] [decimal](12, 3) NULL,
[c_amount] [money] NULL,
[c_score] [money] NULL,
[c_gds_type] [varchar](20) NULL,
[c_pro_status] [varchar](20) NULL,
[c_present_name] [varchar](40) NULL,
[c_type] [varchar](20) NULL,
[c_seller] [varchar](10) NULL,
[c_charger] [varchar](10) NULL,
[c_in_code] [varchar](20) NULL,
[c_note] [varchar](100) NULL,
[c_store_id] [varchar](20) NULL
) ON [PRIMARY]
end
if exists (select * from tempdb.dbo.sysobjects where id=object_id('tempdb..#tb_o_sale'))
BEGIN
drop table #tb_o_sale
END
select c_guid,MIN(c_identity) as c_identity into #tb_o_sale
from tb_o_sale
where c_identity>(select isnull(c_id,0)
from tb_trans_status where c_proc='销售分拆')
group by c_guid
having count(*)>1
insert into tb_o_sale_err(
c_guid,c_identity,c_pos_identity,c_id,c_computer_id,c_datetime,c_cashier,c_flag,
c_cardno,c_adno,c_gcode,c_subcode,c_pt_cost,c_price,c_price_pro,c_price_disc,c_qtty,
c_amount,c_score,c_gds_type,c_pro_status,c_present_name,c_type,c_seller,c_charger,
c_in_code,c_note,c_store_id
)
select c_guid,c_identity,c_pos_identity,c_id,c_computer_id,c_datetime,c_cashier,c_flag,
c_cardno,c_adno,c_gcode,c_subcode,c_pt_cost,c_price,c_price_pro,c_price_disc,c_qtty,
c_amount,c_score,c_gds_type,c_pro_status,c_present_name,c_type,c_seller,c_charger,
c_in_code,c_note,c_store_id
from tb_o_sale(nolock)
where c_identity>(select isnull(c_id,0) from tb_trans_status where c_proc='销售分拆')
and (exists (select * from tb_o_sg (nolock) where tb_o_sale.c_guid=tb_o_sg.c_guid)
or exists (select c_guid from #tb_o_sale b where tb_o_sale.c_guid=b.c_guid and tb_o_sale.c_identity<>b.c_identity))
delete from tb_o_sale
where c_identity>(select isnull(c_id,0) from tb_trans_status where c_proc='销售分拆')
and (exists (select * from tb_o_sg (nolock) where tb_o_sale.c_guid=tb_o_sg.c_guid)
or exists (select c_guid from #tb_o_sale b where tb_o_sale.c_guid=b.c_guid and tb_o_sale.c_identity<>b.c_identity))
go