文章目录
- 成品库存周转率报表(一)
-
- 每日库存结存到表单《历史库存信息》
- 报表逻辑
- 报表设计
-
- 过滤框
- 简单账表界面
- 存储过程,根据传入条件获取并计算返回数据
- 报表服务插件
- 简单账表绑定数据源插件
- 绑定权限,发布,授权即可访问
成品库存周转率报表(一)
每日库存结存到表单《历史库存信息》
生成历史库存
每日库存存储
报表逻辑
组织=供应链中心,仓库=成品仓,区间可选,可单独搜索某物料
(1)库存数取自《历史库存信息》
(2) 期初库存为起始日期的查询库存,期末库存为结束日期的查询库存
(3)平均库存数量=(期初库存数量+期末库存数量)/2
(4)生产入库数量为选定日期范围内生产入库单的数量(按审核日期)
(5)销售出库数量为选定日期范围内销售出库单数量(按审核日期)
(6)产品库存周转率=360/(结束日期-起始日期)*(销售出库数量/平均库存数量)
(7)产品库存周转天数=360/库存周转率
报表设计
过滤框
简单账表界面
存储过程,根据传入条件获取并计算返回数据
CREATE PROCEDURE XXXX_PR_STK_ITORPT(
@STOCKID INT,
@BEGINTIME VARCHAR(20),
@ENDTIME VARCHAR(20),
@t VARCHAR(100)
)
AS
BEGIN
--传入开始时间6.2 ,结束时间7.23
--DECLARE @BEGINTIME VARCHAR(20)
--SET @BEGINTIME='2024-06-02 00:00:00'
--DECLARE @ENDTIME VARCHAR(20)
--SET @ENDTIME='2024-07-23 00:00:00'
--DECLARE @STOCKID INT
--SET @STOCKID=493513
--SELECT TOP 1000 * FROM XXXX_T_STK_HisInventory
DECLARE @ENDTIME1 VARCHAR(10);
SET @ENDTIME1=(
SELECT
CONVERT(VARCHAR(10),DATEADD(D,1,TRY_CAST(@ENDTIME as datetime)),23)
)
--SELECT CONVERT(varchar(10), GETDATE(), 23)
--期初结存库存数
SELECT t0.F_XXXX_MATERIALID FMATERIALID
,t1.FNUMBER FMATERIALNUMBER
, t0.F_XXXX_StockQty FQTY
INTO #tab1
FROM XXXX_T_STK_HisInventory t0 JOIN T_BD_MATERIAL t1 ON t1.FMATERIALID=t0.F_XXXX_MATERIALID
WHERE CONVERT(varchar(10), t0.F_XXXX_DATE, 23)=@BEGINTIME
AND t0.F_XXXX_StockId=@STOCKID
AND t0.F_XXXX_StockOrgId=100006
--期末结存库存数
SELECT t0.F_XXXX_MATERIALID FMATERIALID
,t1.FNUMBER FMATERIALNUMBER
, t0.F_XXXX_StockQty FQTY
INTO #tab2
FROM XXXX_T_STK_HisInventory t0 LEFT JOIN T_BD_MATERIAL t1 ON t1.FMATERIALID=t0.F_XXXX_MATERIALID
WHERE CONVERT(varchar(10), t0.F_XXXX_DATE, 23)=@ENDTIME
AND t0.F_XXXX_StockId=@STOCKID
AND t0.F_XXXX_StockOrgId=100006
--期间销售出库数
SELECT
t2.FMATERIALID fmaterialid
--,t2.FSTOCKID
, SUM(t2.FBASEUNITQTY) fqty
INTO #tab3
FROM T_SAL_OUTSTOCK t0
LEFT OUTER JOIN T_SAL_OUTSTOCKFIN t1 ON t0.FID = t1.FID
LEFT OUTER JOIN T_SAL_OUTSTOCKENTRY t2 ON t0.FID = t2.FID
--LEFT OUTER JOIN t_BD_Stock st28 ON t2.FSTOCKID = st28.FStockId
LEFT OUTER JOIN t_BD_MaterialBase st238 ON t2.FMATERIALID = st238.FMATERIALID
LEFT OUTER JOIN t_BD_MaterialBase st239 ON t2.FMATERIALID = st239.FMATERIALID
WHERE (((((((t0.FAPPROVEDATE >= @BEGINTIME) AND (t0.FAPPROVEDATE < @ENDTIME1))
AND t0.FSTOCKORGID = 100006) AND ((t1.FISGENFORIOS = '0' AND (st238.FERPCLSID <> '6'))
AND (st239.FSUITE <> '1'))) AND t0.FOBJECTTYPEID = 'SAL_OUTSTOCK') AND t0.FCANCELSTATUS = 'A')
AND t2.FSTOCKID=@STOCKID
--AND ((st28.FNUMBER >= '02') AND (st28.FNUMBER <= '02'))
) GROUP BY t2.FMATERIALID
--期间产成品入库
SELECT t1.FMATERIALID fmaterialid
--, t1.FSTOCKID fstockid
, SUM(t1.FBASEREALQTY) fqty
INTO #tab4
FROM T_PRD_INSTOCK t0
LEFT OUTER JOIN T_PRD_INSTOCKENTRY t1 ON t0.FID = t1.FID
LEFT JOIN T_PRD_MO t2 ON t2.fid=t1.FMoId
LEFT JOIN T_BAS_ASSISTANTDATAENTRY_L t3 ON t3.FENTRYID=t2.F_XXXX_WKTYPE
LEFT JOIN dbo.T_BAS_BILLTYPE_L t4 ON t4.FBILLTYPEID=t2.FBILLTYPE
--LEFT OUTER JOIN t_BD_Stock st17 ON t1.FSTOCKID = st17.FStockId
WHERE (((((((t0.FAPPROVEDATE >= @BEGINTIME) AND (t0.FAPPROVEDATE < @ENDTIME1))
AND t0.FSTOCKORGID = 100006) AND t0.FENTRUSTINSTOCKID = 0)
AND t0.FFORMID = 'PRD_INSTOCK') AND t0.FCANCELSTATUS = 'A')
AND t1.FSTOCKID =@STOCKID
AND t4.FNAME='汇报入库-普通生产'
AND t3.FDATAVALUE IN ('普通生产订单','研发试制订单','销售改机订单','PCBA加工订单')
--AND ((st17.FNUMBER >= '02') AND (st17.FNUMBER <= '02'))
) GROUP BY t1.FMATERIALID
--sqlserver 声明小数
DECLARE @daterate NUMERIC(10,2)
SET @daterate=(SELECT ROUND(isnull(360.0/DATEDIFF(DAY,@BEGINTIME,@ENDTIME),0),2))
SELECT ROW_NUMBER() OVER ( ORDER BY m2.fmaterialid ) FID
,493513 FSTOCKID
,'02' AS FSTOCKNUMBER
,'成品仓' AS FSTOCKNAME
, m2.*
,C