库存统计情况分析(如解决好,可另加分!!!)急…… (150分)

  • 主题发起人 主题发起人 hqlww
  • 开始时间 开始时间
H

hqlww

Unregistered / Unconfirmed
GUEST, unregistred user!
在做仓库管理系统中,建立物资字典的时候建立了当前库存、月初库存、本月入库、本月出库
月末结存……入库表与出库表我是分开建的,不是合起来建立一个收发存表
到了月末,需要对库存情况进行统计,如何实现月末结存=月初库存+本月入库-本月出库(这里
的本月入库,本月出库必须从入库单表,出库单表中读出,限定查询时间为一个月的)因为
仓库不一定很吻合在一个月的第一天进行结存核算。当结存核算后,将物资字典中的本月入库、
本月出库的数量减去从入库单表所sum的物资数量,剩下的书这个月的入库记录,可以继续向
下滚动。请问如何实现这样的功能?
如果有更好的结构,请指教!?谢谢!如解决好,可另加分!!!

物资字典:xc_wzzd入库物资:xc_entity出库物资:xc_accept结存物资:xc_jiecun
如何实现将出库资料的本月出库,本月入库的信息统计入结存物资表中?这样的SQL语句怎么写?
CREATE PROCEDURE [wzzdjiecun] @yearmon char(20),@date0 char(20),@date1 char(20) AS
select mate_id,rksl=sum(fact_count) into #ls1 from xc_rkwz where ruku_date between @date0 and @date1 group by mate_id
update xc_wzzd set wz_qmjc=#ls1.rksl+wz_qckc,wz_rksl=wz_rksl-#ls1.rksl,wz_qckc=wz_qmjc from xc_wzzd,#ls1 where xc_wzzd.wz_id=#ls1.mate_id
select lingwz_id,cksl=sum(lingwz_count) into #ls2 from xc_accept where ling_date between @date0 and @date1 group by lingwz_id
update xc_wzzd set wz_qmjc=wz_qckc-#ls2.cksl,wz_cksl=wz_cksl-#ls2.cksl,wz_qckc=wz_qmjc from xc_wzzd,#ls2 where lingwz_id=wz_id

select space(20) as wz_rq,* into #ls3 from xc_wzzd
insert into xc_jiecun select * from #ls3
update xc_jiecun set wz_rq=@yearmon from #ls1,#ls2 where wz_rq=''
 
一般来说仓库管理都差不多,我刚搞完了公司的面仓系统,情况还一般,不算太坏!
我是建立了一个主表,一个入库表,一个出库表,另外还有一个日帐表!
主表记录着物料的基本资料和上月结存,本月结存,本月出入库总数
日帐表表记录某种物料当天的所有出入库总数和当日结存数 (建日帐表主要是方便会计对帐)
余下出入库明细只记录物料的出入库的详细情况,数据的更新是通过触发器来完成!
月底做一次核算,公式就是将上月结存+本月入库-本月出库=本月最后结存
核算后将新的上月结存和本月结存更新到主表中!
一般都是如此。。。不知各位大虾是否有更好的意见!
 
建立一个盘存表,结构类似于库存表,每月进行盘存,记下当时的库存数量,然后统计
 
本月结存=上月结存+本月入库-本月出库
 
采用的办法是写一个存储过程,具体在下面:CREATE PROCEDURE [wzzdjiecun] @yearmon char(20),@date0 char(20),@date1 char(20) AS
select mate_id,rksl=sum(fact_count) into #ls1 from xc_rkwz where ruku_date between @date0 and @date1 group by mate_id
update xc_wzzd set wz_qckc=wz_qmjc,wz_qmjc=#ls1.rksl+wz_qckc,wz_rksl=wz_rksl-#ls1.rksl from xc_wzzd,#ls1 where xc_wzzd.wz_id=#ls1.mate_id
select lingwz_id,cksl=sum(lingwz_count) into #ls2 from xc_accept where ling_date between @date0 and @date1 group by lingwz_id
update xc_wzzd set wz_qmjc=wz_qmjc-#ls2.cksl,wz_cksl=wz_cksl-#ls2.cksl from xc_wzzd,#ls2 where lingwz_id=wz_id
select space(20) as wz_rq,* into #ls3 from xc_wzzd
insert into xc_jiecun select * from #ls3
update xc_jiecun set wz_rq=@yearmon where wz_rq=''
在Sql中写的,具体在 Delphi中可以调用,写出来为了大家多交流。谁有更好的办法,请与我联系。
hqlww@263.net
 
我的是一个进出表,一个库存表。在库存表中又截止的日期和截止的单号。
 
物资字典:xc_wzzd入库物资:xc_entity出库物资:xc_accept结存物资:xc_jiecun
如何实现将出库资料的本月出库,本月入库的信息统计入结存物资表中?这样的SQL语句怎么写?
CREATE PROCEDURE [wzzdjiecun] @yearmon char(20),@date0 char(20),@date1 char(20) AS
select mate_id,rksl=sum(fact_count) into #ls1 from xc_rkwz where ruku_date between @date0 and @date1 group by mate_id
update xc_wzzd set wz_qmjc=#ls1.rksl+wz_qckc,wz_rksl=wz_rksl-#ls1.rksl,wz_qckc=wz_qmjc from xc_wzzd,#ls1 where xc_wzzd.wz_id=#ls1.mate_id
select lingwz_id,cksl=sum(lingwz_count) into #ls2 from xc_accept where ling_date between @date0 and @date1 group by lingwz_id
update xc_wzzd set wz_qmjc=wz_qckc-#ls2.cksl,wz_cksl=wz_cksl-#ls2.cksl,wz_qckc=wz_qmjc from xc_wzzd,#ls2 where lingwz_id=wz_id

select space(20) as wz_rq,* into #ls3 from xc_wzzd
insert into xc_jiecun select * from #ls3
update xc_jiecun set wz_rq=@yearmon from #ls1,#ls2 where wz_rq=''
 
CREATE PROCEDURE [wzzdjiecun] @yearmon char(20),@date0 char(20),@date1 char(20) AS
update xc_wzzd set wz_qckc=wz_qmjc
select space(20) as wz_rq,* into #ls3 from xc_wzzd
insert into xc_jiecun select * from #ls3
update xc_jiecun set wz_rq=@yearmon where wz_rq=''

select mate_id,rksl=sum(fact_count) into #ls1 from xc_rkwz where ruku_date between @date0 and @date1 group by mate_id
update xc_wzzd set wz_qmjc=#ls1.rksl+wz_qckc,wz_rksl=wz_rksl-#ls1.rksl,wz_qcprice=wz_pprice*wz_qckc,wz_rkprice=wz_rksl*wz_pprice,wz_ckprice=wz_cksl*wz_pprice,wz_qmprice=wz_qmjc*wz_pprice from xc_wzzd,#ls1
where xc_wzzd.wz_id=#ls1.mate_id
update xc_jiecun set wz_qmjc=#ls1.rksl+wz_qckc,wz_rksl=#ls1.rksl,wz_qcprice=wz_pprice*wz_qckc,wz_rkprice=wz_rksl*wz_pprice,wz_ckprice=wz_cksl*wz_pprice,wz_qmprice=wz_qmjc*wz_pprice from xc_jiecun,#ls1
where wz_id=#ls1.mate_id and wz_rq=@yearmon

select lingwz_id,cksl=sum(lingwz_count) into #ls2 from xc_accept where ling_date between @date0 and @date1 group by lingwz_id
update xc_wzzd set wz_qmjc=wz_qmjc-#ls2.cksl,wz_cksl=wz_cksl-#ls2.cksl,wz_qcprice=wz_pprice*wz_qckc,wz_rkprice=wz_rksl*wz_pprice,wz_ckprice=wz_cksl*wz_pprice,wz_qmprice=wz_qmjc*wz_pprice from xc_wzzd,#ls2
where lingwz_id=wz_id
update xc_jiecun set wz_qmjc=wz_qmjc-#ls2.cksl,wz_cksl=#ls2.cksl,wz_qcprice=wz_pprice*wz_qckc,wz_rkprice=wz_rksl*wz_pprice,wz_ckprice=wz_cksl*wz_pprice,wz_qmprice=wz_qmjc*wz_pprice from xc_jiecun,#ls2
where wz_id=lingwz_id and wz_rq=@yearmon



 
hqlww_love,X_man你们好,希望我们多交流!
我的E-mail:hqlww@263.net
 
后退
顶部