系統(tǒng)中有前臺(tái)服務(wù)器和后臺(tái)服務(wù)器,前臺(tái)的銷售數(shù)據(jù)是直接傳到前臺(tái)服務(wù)器的,而后臺(tái)是通過作業(yè)定時(shí)從前臺(tái)獲取銷售記錄的。分析原因:
1 后臺(tái)定時(shí)執(zhí)行沒有執(zhí)行,由于數(shù)據(jù)庫的代理服務(wù)沒有啟動(dòng)或者人為的將作業(yè)停了,導(dǎo)致后臺(tái)定時(shí)執(zhí)行沒有執(zhí)行;處理辦法,啟動(dòng)作業(yè),開啟數(shù)據(jù)庫代理的服務(wù)
2 銷售拆分問題:銷售數(shù)據(jù)傳到后臺(tái)后,系統(tǒng)會(huì)進(jìn)行拆分,拆分完成后,才會(huì)在相關(guān)報(bào)表中體現(xiàn),才會(huì)真正算銷售。銷售拆分出錯(cuò)是絕大多少銷售沒有傳到后臺(tái)的原因。導(dǎo)致這樣的情況一般有下面幾個(gè)情況 1、有人修改tb_trans_status,導(dǎo)致記錄已拆分記錄錯(cuò)誤 處理辦法:修改 tb_trans_status中銷售拆分的id,可以找最大tb_o_sg.c_identity;2、前臺(tái)硬件故障,銷售重復(fù)傳送,特征:tb_o_sale.c_guid重復(fù)處理辦法:刪除重復(fù)的c_guid;3、商品后臺(tái)不存在,這個(gè)一般由于后臺(tái)刪除商品后,沒有及時(shí)傳到前臺(tái),前臺(tái)正好做了銷售,處理辦法:刪除改流水,用正確的商品編碼銷售;4、商品在一個(gè)門店存在2個(gè)部門,銷售拆分時(shí)不知道是哪個(gè)部門算哪個(gè)部門的銷售,處理辦法:刪除錯(cuò)誤的部門。
輔助查詢語句:
/*tb_o_sale.c_guid重復(fù)*/
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)
/*一個(gè)商品在一個(gè)門店存在2個(gè)部門*/
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
/*商品編碼后臺(tái)不存在*/
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
還有一種情況,沒有可用的資源了,比方磁盤空間或者內(nèi)存設(shè)置過低 或者本身服務(wù)器內(nèi)存就比較小
導(dǎo)致服務(wù)被終止,傳輸無法運(yùn)行,我這出現(xiàn)過類似的問題
處理方法:
1 先將數(shù)據(jù)做好備份
2 刪除重復(fù)數(shù)據(jù)
3 觀察作業(yè)是否成功
以/*tb_o_sale.c_guid重復(fù)*/為例:
第一步:
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)
第三步:
查看作業(yè)是否成功,實(shí)時(shí)銷售監(jiān)察是否正確
如果不想讓錯(cuò)誤數(shù)據(jù)影響當(dāng)天銷售,可以建立作業(yè),將錯(cuò)誤數(shù)據(jù)做好備份,讓剩余數(shù)據(jù)正常拆分,建議一天晚上執(zhí)行一次
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