Erp:原料投入产出报表

USE [ChangHongWMS612]
GO

/****** Object: StoredProcedure [dbo].[st_WMS_RptMaterialInOutDaily] Script Date: 05/12/2015 17:24:27 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
/*create by :zhuss

Date:2014-12-19
Remark:原料投入产出报表
原存储过程名称:WMS_RptMaterialInOutDaily
*/
ALTER Proc [dbo].[st_WMS_RptMaterialInOutDaily](
@StartDate varchar(10)= ‘‘,
@EndDate varchar(10)=‘‘,
@MaterialNO varchar(50) = ‘‘
)
as
if @EndDate=‘‘ select @EndDate=CONVERT(varchar(10),getdate(),121)
select @StartDate = CONVERT(varchar(10),convert(datetime,@StartDate),121)
select @EndDate = CONVERT(varchar(10),convert(datetime,@EndDate),121)

exec st_WMS_JobReDoMaterialInOut ‘RptMaterialInOutDaily‘

select t1.* ,
BillAges = datediff(day,
(select top 1 m.CreateTime
from KIT_MaterialStockIn m
where m.MQty>0 and m.RawNO = t1.MaterialNO
and m.SupplyNO = t1.SupplyNO
order by m.CreateTime desc)
,getdate())

from WMS_RptMaterialInOutDaily t1
where CurrDate between @StartDate and @EndDate
and (@MaterialNO = ‘‘ or (MaterialNO like ‘%‘ [email protected]+‘%‘ or MaterialName like ‘%‘ [email protected]+‘%‘))
order by CurrDate,MaterialNO

GO

---------------------------------------

USE [ChangHongWMS612]
GO

/****** Object: StoredProcedure [dbo].[st_WMS_JobReDoMaterialInOut] Script Date: 05/12/2015 17:33:05 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

/*
create by :hz
create time:2014-12-19
Remark:执行原料出入库
原存储过程名:JOB_ReDoMaterialInOut
*/
ALTER proc [dbo].[st_WMS_JobReDoMaterialInOut]
(
--WMS_RptMaterialInOutDaily
@JobName varchar(50) = ‘RptMaterialInOutDaily‘[email protected]_DoJob varchar(50) = ‘‘
)
as

declare @CurrDate varchar(10), @UpdateDate datetime, @Feeding_Time varchar(19), @CurrTime varchar(19)
declare CursorD cursor local
For
select distinct convert(varchar(10),FeedTime,121), ApprovedDate = CONVERT(varchar(14),CreateTime,121)+‘00:00‘,convert(varchar(19),FeedTime,121)
from KIT_FeedSupply
where CreateTime>= CONVERT(varchar(10),GETDATE(),121)
union
select ChgDate = convert(varchar(10),HopperTime,121), ApprovedDate = CONVERT(varchar(14),CreateTime,121)+‘00:00‘,convert(varchar(19),HopperTime,121)
from KIT_HopperRecord

Open CursorD
Fetch next From CursorD Into @CurrDate, @UpdateDate, @Feeding_Time
While(@@Fetch_Status = 0)
Begin
if(@JobName = ‘‘ or @JobName = ‘RptMaterialInOutDaily‘)
begin
if(exists(select * from WMS_JobDoRpt
where JobName = ‘RptMaterialInOutDaily‘ and CurrDate = @CurrDate and UpdateTime<[email protected])
or not exists(select * from WMS_JobDoRpt
where JobName = ‘RptMaterialInOutDaily‘ and CurrDate = @CurrDate))
begin
select @CurrTime = @CurrDate + ‘ 23:59:59‘

exec [dbo].[st_WMS_JobGenRptMaterialInOut] @CurrTime
end
end

Fetch next From CursorD Into @CurrDate, @UpdateDate, @Feeding_Time
End
Close CursorD
Deallocate CursorD

GO

------------------------------------------------

USE [ChangHongWMS612]
GO

/****** Object: StoredProcedure [dbo].[st_WMS_JobGenRptMaterialInOut] Script Date: 05/12/2015 17:42:39 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

/*
Create by:hz
Create time:2014-12-18
Remark:原料投入产出日报表
原存储过程名:Job_GenRptMaterialInOut
--2014-12-18 hz ChiefMESNew 修改为ChangHong_612
exec st_WMS_JobGenRptMaterialInOut ‘2015-01-27 08:30:00‘
*/
ALTER Proc [dbo].[st_WMS_JobGenRptMaterialInOut](
@CurrDate varchar(19) = ‘2014-11-30 08:30:00‘[email protected]_Date varchar(19) = ‘2014-11-30 08:30:00‘
)
as

declare @Date varchar(10), @NextDate varchar(10)
declare @BeginDate varchar(19), @EndDate varchar(19)
if(@CurrDate = ‘‘)
begin
set @Date = convert(varchar(10),dateadd(day,-1,GETDATE()),121)
end
else
begin
select @Date=convert(varchar(10), @CurrDate,120)
end

select @NextDate = CONVERT(varchar(10),dateadd(day,1,@Date),121)

declare @MonthFrom varchar(10)
select @MonthFrom = convert(varchar(10),DATEADD(day,-DATEPART(day, @CurrDate)+1,@CurrDate ),121) --月初

select @[email protected]+‘ 08:30:00‘, @[email protected]+‘ 08:30:00‘

delete from WMS_RptMaterialInOutDaily where CurrDate = @Date
if object_id(‘tempdb..#t_RptMaterialInOutDaily‘) is not null drop table #t_RptMaterialInOutDaily
select * into #t_RptMaterialInOutDaily from WMS_RptMaterialInOutDaily where 1 = 0
create table #t_Material(MaterialNO varchar(50),MaterialName varchar(100), SupplyCode varchar(50), FeedGrade varchar(50), MaterialClass varchar(100), Unit varchar(50))

insert into #t_Material(MaterialNO,MaterialName, SupplyCode,FeedGrade,MaterialClass, Unit)
select distinct MaterialNO, MaterialName, SupNO, FeedGrade, MaterialsClassification, Units
from ChangHong_612.dbo.MES_MaterialPacket

insert into #t_RptMaterialInOutDaily(CurrDate, MaterialNO, MaterialName, SupplyNO,MaterialClass, FeedGrade, Unit, Process, CostCenter)
select @Date, MaterialNO, MaterialName, SupplyCode,MaterialClass, FeedGrade, Unit, ‘612‘,‘8002107‘
from #t_Material

--仓库本日领入
update t1 set TodayLinInQty =(select SUM(m.MQty)
from KIT_MaterialStockIn m
where m.MQty>0 and charindex(‘转入‘,isnull(m.StateDesc,‘‘))=0
and isnull(m.CheckTime,m.CreateTime) between @BeginDate and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--仓库月累计领入
update t1 set MonthLinInQty =(select SUM(m.MQty)
from KIT_MaterialStockIn m
where m.MQty>0 and charindex(‘转入‘,isnull(m.StateDesc,‘‘))=0
and isnull(m.CheckTime,m.CreateTime) between @MonthFrom and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--仓库本日转入
update t1 set TodayZhuanInQty =(select SUM(m.MQty)
from KIT_MaterialStockIn m
where m.MQty>0 and charindex(‘转入‘,isnull(m.StateDesc,‘‘))>0
and isnull(m.CheckTime,m.CreateTime) between @BeginDate and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--仓库月累计转入
update t1 set MonthZhuanInQty =(select SUM(m.MQty)
from KIT_MaterialStockIn m
where m.MQty>0 and charindex(‘转入‘,isnull(m.StateDesc,‘‘))>0
and isnull(m.CheckTime,m.CreateTime) between @MonthFrom and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--转入单位
update t1 set ZhunInUnit =(select max(Unit)
from KIT_MaterialStockIn m
where m.MQty>0 and charindex(‘转入‘,isnull(m.StateDesc,‘‘))>0
and isnull(m.CheckTime,m.CreateTime) between @BeginDate and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1
--select * from WMS_RptMaterialInOutDaily where CurrDate = ‘2014-11-19‘
--select * from KIT_MaterialStockIn
--select * from WMS_RptMaterialInOutDaily where isnull(TodayZhuanOutQty,0)<>isnull(BZTodayLinIn,0) and CurrDate=‘2014-11-20‘
--select * from KIT_MaterialStockIn where MATERIAL=‘810498396‘ and C_DATE>=‘2014-11-20‘
--仓库本日发出

update t1 set TodayOutQty =(select SUM(isnull(m.GQty,0)-ISNULL(m.RQty,0))
from KIT_MaterialStockIn m
where (m.GQty>0 or m.RQty>0) and charindex(‘转移‘,isnull(m.StateDesc,‘‘))=0
and isnull(m.CheckTime,m.CreateTime) between @BeginDate and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--仓库月累计发出
update t1 set MonthOutQty =(select SUM(isnull(m.GQty,0)-ISNULL(m.RQty,0))
from KIT_MaterialStockIn m
where (m.GQty>0 or m.RQty>0) and charindex(‘转移‘,isnull(m.StateDesc,‘‘))=0
and isnull(m.CheckTime,m.CreateTime) between @MonthFrom and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--仓库本日转出
update t1 set TodayZhuanOutQty =(select SUM(m.GQty)
from KIT_MaterialStockIn m
where m.GQty>0 and charindex(‘转移‘,isnull(m.StateDesc,‘‘))>0
and isnull(m.CheckTime,m.CreateTime) between @BeginDate and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--仓库月累计转出
update t1 set MonthZhuanOutQty =(select SUM(m.GQty)
from KIT_MaterialStockIn m
where m.GQty>0 and charindex(‘转移‘,isnull(m.StateDesc,‘‘))>0
and isnull(m.CheckTime,m.CreateTime) between @MonthFrom and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--转出单位
update t1 set ZhunOutUnit =(select max(m.Unit)
from KIT_MaterialStockIn m
where m.GQty>0 and charindex(‘转移‘,isnull(m.StateDesc,‘‘))>0
and isnull(m.CheckTime,m.CreateTime) between @BeginDate and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--昨日结存
declare @LastDate varchar(10), @LastBeginDate varchar(19), @LastEndDate varchar(19)
select @LastDate = CONVERT(varchar(10),dateadd(day,-1,convert(datetime,@date)),121)
select @LastBeginDate = @LastDate+‘ 08:30:00‘, @LastEndDate = @Date+‘ 08:30:00‘

update t set LastStockQty =(
select top 1 r.MQty
from KIT_StockBatchCheck r
where State =5 and isnull(r.CheckTime,r.CreateTime) between @LastBeginDate and @LastEndDate
and r.RawNo = t.MaterialNO
and r.SupplyNo = t.SupplyNO
order by r.CreateTime desc)
from #t_RptMaterialInOutDaily t

update t set LastStockQty =(select top 1 TodayStockQty from WMS_RptMaterialInOutDaily r where r.SupplyNO = t.SupplyNO and r.MaterialNO = t.MaterialNO and r.CurrDate = @LastDate)
from #t_RptMaterialInOutDaily t
where t.LastStockQty is null

--班组本日领入
update t1 set BZTodayLinIn =(select SUM(isnull(m.MQty,0)-ISNULL(m.RQty,0))
from KIT_StockDetail m
where (m.MQty>0 or m.RQty>0)
and isnull(m.CheckTime,m.CreateTime) between @BeginDate and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--班组月累计领入
update t1 set BZMonthLinIn =(select SUM(isnull(m.MQty,0)-ISNULL(m.RQty,0))
from KIT_StockDetail m
where (m.MQty>0 or m.RQty>0)
and isnull(m.CheckTime,m.CreateTime)between @MonthFrom and @EndDate
and m.RawNO = t1.MaterialNO and m.SupplyNO = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--班组本日加料
update t1 set BZTodayPutQty =(select SUM(m.feedingQty)
from ChangHong_612.dbo.MES_Material m
where m.feedingTime between @BeginDate and @EndDate
and m.MaterialNO = t1.MaterialNO and m.supplier = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--班组月累计加料
update t1 set BZMonthPutQty =(select SUM(m.feedingQty)
from ChangHong_612.dbo.MES_Material m
where m.feedingTime between @MonthFrom and @EndDate
and m.MaterialNO = t1.MaterialNO and m.supplier = t1.SupplyNO
)
from #t_RptMaterialInOutDaily t1

--班组昨日结存
update t1 set BZLastStockQty =(select top 1 MQty
from KIT_StockCheck r
where State =6 and isnull(r.CheckTime,r.CreateTime) between @LastBeginDate and @LastEndDate
and r.RawNo = t1.MaterialNO
and r.SupplyNo = t1.SupplyNO
order by r.CreateTime desc)
from #t_RptMaterialInOutDaily t1

update t set BZLastStockQty =(select top 1 BZTodayStock from WMS_RptMaterialInOutDaily r where r.SupplyNO = t.SupplyNO and r.MaterialNO = t.MaterialNO and r.CurrDate = @LastDate)
from #t_RptMaterialInOutDaily t
where BZLastStockQty is null

--班组本日结存
update t set BZTodayStock = isnull(BZLastStockQty,0)+ISNULL(BZTodayLinIn,0)-ISNULL(BZTodayPutQty,0)
from #t_RptMaterialInOutDaily t

--料斗期初余料
update t1 set HopperTermBeginQty =isnull((select top 1 HopperTermEndQty from WMS_RptMaterialInOutDaily r where r.SupplyNO = t1.SupplyNO and r.MaterialNO = t1.MaterialNO and r.CurrDate = @LastDate
),0)
from #t_RptMaterialInOutDaily t1

--料斗本日加料
update t1 set HopperTodayPutQty = BZTodayPutQty
from #t_RptMaterialInOutDaily t1

--仓库本日结存:仓库昨日结存+仓库本日领入+仓库本日转入-仓库本日发出-仓库本日转出
update t set TodayStockQty =isnull(LastStockQty,0)+isnull(TodayLinInQty,0)+isnull(TodayZhuanInQty,0)-isnull(TodayOutQty,0)-isnull(TodayZhuanOutQty,0)
from #t_RptMaterialInOutDaily t

--update t1 set HopperMonthPutQty =(select SUM(m.T_NUM)
-- from Kitting.dbo.kitting_h_p_no_num m
-- where m.C_DATE between @MonthFrom and @EndDate
-- and m.HH_GNO = t1.MaterialNO and m.SUP_NO = t1.SupplyNO
-- )
--from #t_RptMaterialInOutDaily t1

--本日消耗
update t1 set TodayConsumQty =isnull(TodayConsumQty,0)+ isnull((select SUM(r.ActualQty*(MaterialQty1/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.MaterialNo1 = t1.MaterialNO
and r.SupplyCode = t1.SupplyNO and r.MaterialSumQty>0
),0)
from #t_RptMaterialInOutDaily t1

update t1 set TodayConsumQty =isnull(TodayConsumQty,0)+ isnull((select SUM(r.ActualQty*(MaterialQty2/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.MaterialNo2 = t1.MaterialNO
and r.SupplyCode2 = t1.SupplyNO and r.MaterialSumQty>0
),0)
from #t_RptMaterialInOutDaily t1

update t1 set TodayConsumQty =isnull(TodayConsumQty,0)+ isnull((select SUM(r.ActualQty*(MaterialQty3/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.MaterialNo3 = t1.MaterialNO
and r.SupplyCode3 = t1.SupplyNO and r.MaterialSumQty>0
),0)
from #t_RptMaterialInOutDaily t1

update t1 set TodayConsumQty = isnull(TodayConsumQty,0)+isnull((select SUM(r.ActualQty*(r.SheMuQty/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.SheMuCode = t1.MaterialNO
and r.SheMuSupply = t1.SupplyNO and r.MaterialSumQty>0
),0)
from #t_RptMaterialInOutDaily t1

update t1 set TodayConsumQty = isnull(TodayConsumQty,0)+isnull((select SUM(r.ActualQty*(r.SheMuQty1/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.SheMuCode1 = t1.MaterialNO
and r.SheMu1Supply = t1.SupplyNO and r.MaterialSumQty>0
),0)
from #t_RptMaterialInOutDaily t1

update t1 set TodayConsumQty = isnull(TodayConsumQty,0)+isnull((select SUM(r.ActualQty*(r.CycleQty1/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.CycleNo1 = t1.MaterialNO
and r.Cycle1Supply = t1.SupplyNO and r.MaterialSumQty>0
),0)
from #t_RptMaterialInOutDaily t1

update t1 set TodayConsumQty = isnull(TodayConsumQty,0)+isnull((select SUM(r.ActualQty*(r.CycleQty2/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.CycleNo2 = t1.MaterialNO
and r.Cycle2Supply = t1.SupplyNO
),0)
from #t_RptMaterialInOutDaily t1

update t1 set TodayConsumQty = isnull(TodayConsumQty,0)+isnull((select SUM(r.ActualQty*(r.CycleQty3/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.CycleNo3 = t1.MaterialNO
and r.Cycle3Supply = t1.SupplyNO and r.MaterialSumQty>0
),0)
from #t_RptMaterialInOutDaily t1

--料斗期末余料:取当日投料报表班组余料
update t1 set HopperTermEndQty = isnull(HopperTermEndQty,0)+ isnull((select SUM(r.JiaoPlusQty*(r.MaterialQty1/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.MaterialNo1 = t1.MaterialNO and r.MaterialSumQty>0
and r.SupplyCode = t1.SupplyNO),0)
from #t_RptMaterialInOutDaily t1

update t1 set HopperTermEndQty = isnull(HopperTermEndQty,0)+ isnull((select SUM(r.JiaoPlusQty*(r.MaterialQty2/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.MaterialNo2 = t1.MaterialNO and r.MaterialSumQty>0
and r.SupplyCode2 = t1.SupplyNO),0)
from #t_RptMaterialInOutDaily t1

update t1 set HopperTermEndQty = isnull(HopperTermEndQty,0)+ isnull((select SUM(r.JiaoPlusQty*(r.MaterialQty3/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.MaterialNo3 = t1.MaterialNO and r.MaterialSumQty>0
and r.SupplyCode3 = t1.SupplyNO),0)
from #t_RptMaterialInOutDaily t1

update t1 set HopperTermEndQty = isnull(HopperTermEndQty,0)+ isnull((select SUM(r.JiaoPlusQty*(r.SheMuQty/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.SheMuCode = t1.MaterialNO and r.MaterialSumQty>0
and r.SheMuSupply = t1.SupplyNO),0)
from #t_RptMaterialInOutDaily t1

update t1 set HopperTermEndQty = isnull(HopperTermEndQty,0)+ isnull((select SUM(r.JiaoPlusQty*(r.SheMuQty1/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.SheMuCode1 = t1.MaterialNO and r.MaterialSumQty>0
and r.SheMu1Supply = t1.SupplyNO),0)
from #t_RptMaterialInOutDaily t1

update t1 set HopperTermEndQty = isnull(HopperTermEndQty,0)+ isnull((select SUM(r.JiaoPlusQty*(r.CycleQty1/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.CycleNo1 = t1.MaterialNO and r.MaterialSumQty>0
and r.Cycle1Supply = t1.SupplyNO),0)
from #t_RptMaterialInOutDaily t1

update t1 set HopperTermEndQty = isnull(HopperTermEndQty,0)+ isnull((select SUM(r.JiaoPlusQty*(r.CycleQty2/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.CycleNo1 = t1.MaterialNO and r.MaterialSumQty>0
and r.Cycle2Supply = t1.SupplyNO),0)
from #t_RptMaterialInOutDaily t1

update t1 set HopperTermEndQty = isnull(HopperTermEndQty,0)+ isnull((select SUM(r.JiaoPlusQty*(r.CycleQty3/r.MaterialSumQty))
from WMS_RptMaterialPutDaily r
where r.CurrDate = t1.CurrDate and r.CycleNo1 = t1.MaterialNO and r.MaterialSumQty>0
and r.Cycle3Supply = t1.SupplyNO),0)
from #t_RptMaterialInOutDaily t1

--混料结存(暂存)

update t1 set TodayMixQty =
(select SUM(r.OverQty)
from KIT_MixOver r
where r.RawNO = t1.MaterialNO and STATE = 0
and r.SupplyNO = t1.SupplyNO
and r.MixTime <[email protected]
)
from #t_RptMaterialInOutDaily t1

--合计库存:仓库本日结存+班组本日结存+料斗本日结存+暂存库存
update t1 set SumStockQty = isnull(TodayStockQty,0)+isnull(BZTodayStock,0)+isnull(HopperTermEndQty,0)+ISNULL(TodayMixQty,0)
from #t_RptMaterialInOutDaily t1

--合计期初库存
update t1 set SumTermBeginQty = (select top 1 SumStockQty from WMS_RptMaterialInOutDaily r where r.SupplyNO = t1.SupplyNO and r.MaterialNO = t1.MaterialNO and r.CurrDate <@MonthFrom)
from #t_RptMaterialInOutDaily t1

--期初库存
update t1 set TermBeginQty = (select top 1 TodayStockQty from WMS_RptMaterialInOutDaily r where r.SupplyNO = t1.SupplyNO and r.MaterialNO = t1.MaterialNO and r.CurrDate <@MonthFrom)
from #t_RptMaterialInOutDaily t1

delete from #t_RptMaterialInOutDaily where isnull(TodayStockQty,0) = 0 and isnull(TodayOutQty,0) = 0
and isnull(LastStockQty,0) = 0 and isnull(ZhunInUnit,0)= 0
and ISNULL(SumStockQty,0) = 0 and isnull(BZTodayStock,0) = 0 and ISNULL(TodayZhuanInQty,0)=0
and ISNULL(TodayZhuanOutQty,0)= 0 and ISNULL(BZTodayLinIn,0)=0 and ISNULL(HopperTodayPutQty,0) = 0
and ISNULL(BZTodayPutQty,0)=0

declare @TodayAffactRows int

insert into WMS_RptMaterialInOutDaily([CurrDate],[SupplyNO]
,[MaterialNO],[MaterialName],[MaterialClass]
,[FeedGrade],[Unit],[SumStockQty],[SumTermBeginQty]
,[TermBeginQty],[LastStockQty],[MonthLinInQty]
,[TodayZhuanInQty],[MonthZhuanInQty],[ZhunInUnit]
,[TodayOutQty],[MonthOutQty],[TodayZhuanOutQty]
,[MonthZhuanOutQty],[ZhunOutUnit],[TodayStockQty]
,[BZSumStockQty],[BZLastStockQty]
,[BZTodayLinIn],[BZMonthLinIn]
,[BZTodayPutQty],[BZMonthPutQty]
,[BZTodayStock],[HopperTermBeginQty]
,[HopperTodayPutQty],[HopperMonthPutQty],[TodayConsumQty]
,[HopperTermEndQty],[AdjustQty]
,[Remark],[Process],[CostCenter],[TodayLinInQty],TodayMixQty
)
select [CurrDate],[SupplyNO]
,[MaterialNO],[MaterialName],[MaterialClass]
,[FeedGrade],[Unit],[SumStockQty],[SumTermBeginQty]
,[TermBeginQty],[LastStockQty],[MonthLinInQty]
,[TodayZhuanInQty],[MonthZhuanInQty],[ZhunInUnit]
,[TodayOutQty],[MonthOutQty],[TodayZhuanOutQty]
,[MonthZhuanOutQty],[ZhunOutUnit],[TodayStockQty]
,[BZSumStockQty],[BZLastStockQty]
,[BZTodayLinIn],[BZMonthLinIn]
,[BZTodayPutQty],[BZMonthPutQty]
,[BZTodayStock],[HopperTermBeginQty]
,[HopperTodayPutQty],[HopperMonthPutQty],[TodayConsumQty]
,[HopperTermEndQty],[AdjustQty]
,[Remark],[Process],[CostCenter],[TodayLinInQty],TodayMixQty
from #t_RptMaterialInOutDaily

select @TodayAffactRows = @@ROWCOUNT
if(@CurrDate = ‘‘) set @CurrDate [email protected]
if(not exists(select * from WMS_JobDoRpt where JobName = ‘RptMaterialInOutDaily‘ and CurrDate = @CurrDate))
begin
insert into WMS_JobDoRpt(JobName,CurrDate,UpdateTime)
select ‘RptMaterialInOutDaily‘,@CurrDate ,GETDATE()
end
else
begin
update WMS_JobDoRpt set Updatetime = getdate() ,LastAffactRows [email protected]
where JobName = ‘RptMaterialInOutDaily‘ and CurrDate = @CurrDate
end
-- select * from RptMaterialInOutDaily
drop table #t_RptMaterialInOutDaily

GO

时间: 2024-10-14 10:58:59

Erp:原料投入产出报表的相关文章

计量经济学投入产出方法(直接消耗系数、完全消耗系数、感应力系数、影响力系数)

简介:分析特定经济系统内投入与产出间数量依存关系的原理和方法.亦称产业部门间分析.它由美国W.里昂惕夫于1936年最早提出.投入产出分析的理论基础是瓦尔拉的一般均衡理论.这种理论认为,资本主义经济通过供求关系和价格波动,可以自动地均衡发展.社会主义国家引入投入产出分析之后,以分工与协作.生产劳动与非生产劳动.劳动价值论.社会再生产理论为其理论基础. 2.1影响力系数和感应力系数的定义及量化方法 2.1.1影响力系数 在专利生产的投入产出框架下,影响力系数是指第j个技术领域增加一个单位的专利产出时

[ASP NET MVC] 使用ReportViewer执行用户端报表定义文件(.rdlc)产出报表

使用ReportViewer执行用户端报表定义文件(.rdlc)来产出报表 前言 以往使用ASP.NET WebForm进行网站开发时,笔者面对报表的产出多会使用ReportViewer来进行,并且搭配用户端报表定义文件(.rdlc)来设计报表外观,其实是相当灵活的解决方案:如今使用ASP.NET MVC进行开发,虽然View中无法加入任何WebForm Control了,但我们依旧可以建立一个共用WebForm页面,在此页面上加入熟悉的ReportViewer来协助产出报表.详细实践细节请参考

ERP入库与售价报表

use Test go SELECT MOCTF.TF001+'-'+MOCTF.TF002 as 生产入库单号 ,MOCTF.TF003 as 入库日期 ,MOCTG.TG004 as 品号 ,MOCTG.TG005 as 品名 ,MOCTG.TG006 as 规格 ,MOCTG.TG007 as 单位 ,MOCTG.TG011 as 数量 ,MOCTA.TA026+'-'+MOCTA.TA027+'-'+MOCTA.TA028 as 订单单号 ,COPTD.TD011 as 售价 ,COPT

不要拿ERP的报表忽悠领导!——一个报表引发的企业经营反思

文 | 帆软数据应用研究院船长   领导的经营决策能只依赖于ERP报表吗? 不能! 1. ERP报表个性化不足:企业经营决策报表是为企业高层.管理层服务的,格式.维度.指标.数据等依据高层.管理层自身管理需要决定,是不同企业.领导的个性化需求: 2. ERP报表数据不足:企业经营决策报表全面反映企业运营状况,信息来源不仅仅是ERP,还有POS.CRM.OA.生产制造系统.供应链系统和其他各个信息系统: 3. ERP报表维度不足:企业经营决策报表对指标和维度关注,ERP报表只是数据库数据的格式化呈

联想ERP项目实施案例分析(10):回到最初再反思IT价值

联想ERP项目实施案例分析(10):回到最初再反思IT价值投入上千万(未来每年的维护费也非常高),投入一年实施时间,高级副总裁亲自挂帅,各级业务部门管理者亲自负责.骨干业务人员充当区域IT实施者/推进者/先锋示范者,推动力度不可谓不大,投入不可谓不大.我回想了回想,联想日常的管理水平非常高.运行力非常高.精细化管理程度也非常高.组织设计/人员分工/专业能力/士气都不错,不像非常多中国企业本身就管理不到位,效率不高往往是由于:层层管控道道审批.老板一言堂/下属谁也不拍板仅仅和稀泥.对计划制定和运行

应用ERP系统与企业的关系

  随着ERP系统的深入发展,越来越多的企业开始实施ERP,ERP实施是借用一种新的管理模式来改造原企业旧的管理模式,是先进的.行之有效的管理思想和方法.ERP软件在实际的推广应用中,其应用深度和广度都不到位,多数企业的效果不显著,没有引起企业决策者的震动和人们的广泛关注.   1.实施ERP是企业管理全方位的变革 企业领导层应该首先是受教育者,其次才是现代管理理论的贯彻者和实施者,规范企业管理及其有关环节,使之成为领导者.管理层及员工自觉的行动,使现代管理意识扎根于企业中,成为企业文化的一部分

想实时查阅报表?请随我来

当市场红利渐渐褪去,在企业经营界,拍脑袋这样的江湖技能已经几乎完全失去效力,而依赖丰富.及时.准确的数据来把脉市场和公司的运营成为企业运营中一项新的必备技能.然而,当企业把各类系统陆续建立起来,开始习惯与数据对话的时候,移动互联的大浪又再次袭来,今后的竞争,只有数据将远远不够,企业更需要的是速度! 试想一下,当你身在外地,而亟需获得一份数据报表的时候,是如何的曲折周转?相关部门又要为此付出多少精力和时间?到最后竟然忙中出错的情况又让人情何以堪?先不要焦虑,来看看这组图: 移动报表示例 这是一组来

FineReport实现java报表统计图表的效果图

Java报表-ERP图表联动 Java报表-多维坐标轴图 Java报表-静态图表 Java报表-时间坐标轴 Java报表-图表报表动态交互 Java报表-图表热点链接 Java报表-图表缩放 Java报表-地图-广州市商场销售分析 Java报表-地图-全国商场销售分析 Java报表-地图-商场柜台销售分析 Java报表-图表分类-甘特图 Java报表-图表分类-工业折线图 Java报表-图表分类-股价图 Java报表-图表分类-交叉图表 Java报表-图表分类-气泡图 Java报表-图表分类-散

国际制造执行系统(MES)应用与发展

某些专家认为,当今制造业的生存三要素是信息技术(IT).供应链管理(SCM)和成批制造技术.使用信息技术就是由依赖人工的作业方式转变为作业的快速化.高效化,大量减少人工介入,降低生产经营成本:供应链管理是从原材料供应到产品出厂的整个生产过程,使物流资源的流通和配置最优化.这和局部优化的区别就是全面最优化:成批制造技术是在合适的时间,生产适量产品的生产计划排产优化技术,并随着生产制造技术的深化,改善对设备的管理.这里,MES技术在企业信息化中扮演着最重要的角色.        一.MES的产生和发