更新装配、精工车间、技术中心、仓储模块,新增工序工价、生产审核、三楼仓库可视化等功能及文档SQL

This commit is contained in:
Developer
2026-07-06 11:21:59 +08:00
parent be0ff91e24
commit 9c1f52078d
43 changed files with 8566 additions and 233 deletions

View File

@@ -0,0 +1,259 @@
USE [ERPTOOL_JY_20250826Back]
GO
-- 核心物料搜索栏增加物料编码查询条件
-- 需求提出人:罗伟
-- 说明:以下过程补充 @物料编码_check、@物料编码 可选参数。未传入物料编码时保持原查询逻辑不变。
-- 备注:修改人:Ld 修改时间:2026-06-29 14:30:00
ALTER PROCEDURE [dbo].[_物料记录_查询新]
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ datetime = null,
@ datetime = null
AS
BEGIN
declare @selectStr nvarchar(4000)
declare @selectStrWhere nvarchar(4000)
set @selectStr =
'SELECT row_number() OVER (ORDER BY b.记录时间) AS id, d.*, CONVERT(int, isnull(出库数, 0)) AS 出库数, isnull(入库数, 0) AS 入库数, 库存管理_货位主文件.货位名称, 单位名称_基础表.单位, isnull(库存数, 0) AS 库存数, 记录时间
FROM (SELECT 物料流水号, 库存数, CONVERT(varchar(10), 操作日期, 23) AS 记录时间 FROM 库存管理_每日库存结余表) AS b
LEFT JOIN (SELECT sum(领料数) AS 出库数, 物料流水号, 领料日期 FROM 仓储管理_出库记录_视图 GROUP BY 物料流水号, 领料日期) AS c ON b.物料流水号 = c.物料流水号 AND c.领料日期 = b.记录时间
LEFT JOIN (SELECT sum(入库数) AS 入库数, 物料流水号, 入库日期 FROM 仓储管理_入库记录_视图 GROUP BY 物料流水号, 入库日期) AS a ON b.物料流水号 = a.物料流水号 AND a.入库日期 = b.记录时间
INNER JOIN (SELECT 物料编码, 名称, 代号, 物料流水号, 货位流水号, 单位流水号 FROM 库存管理_物料主文件_基本) AS d ON b.物料流水号 = d.物料流水号
LEFT JOIN 单位名称_基础表 ON d.单位流水号 = 单位名称_基础表.单位流水号
LEFT JOIN 库存管理_货位主文件 ON d.货位流水号 = 库存管理_货位主文件.货位流水号 '
set @selectStrWhere = ' where 1 = 1 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere + ' and replace(isnull(名称,''''),'' '','''') + replace(isnull(代号,''''),'' '','''') + replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料名称,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere + ' and replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料编码,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere + ' and 记录时间 >= convert(varchar(10),@开始时间,23) and 记录时间 <= convert(varchar(10),@结束时间,23) '
set @selectStr = @selectStr + @selectStrWhere + ' order by 记录时间 desc'
EXEC sp_executesql @selectStr,
N'@物料名称 nvarchar(50),@物料编码 nvarchar(50),@开始时间 datetime,@结束时间 datetime',
@,@,@,@
END
GO
ALTER PROCEDURE [dbo].[_物料记录_查询]
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ datetime = null,
@ datetime = null
AS
BEGIN
declare @selectStr nvarchar(4000)
set @selectStr =
' select sum(convert(int,isnull(出库数,0))) as 出库数,sum(isnull(入库数,0)) as 入库数,sum(isnull(库存数,0)) as 库存数 from (select 物料流水号,库存数,convert(varchar(10),操作日期,23) as 记录时间 from 库存管理_每日库存结余表 where 1 = 1 '
if(@_check = 1)
set @selectStr = @selectStr + ' and convert(varchar(10),操作日期,23) >= @开始时间 and convert(varchar(10),操作日期,23) <= @结束时间 '
set @selectStr = @selectStr +
' ) as b left join (select sum(领料数) as 出库数,物料流水号,领料日期 from 仓储管理_出库记录_视图 where 1=1 '
if(@_check = 1)
set @selectStr = @selectStr + ' and 领料日期 >= @开始时间 and 领料日期 <= @结束时间 '
set @selectStr = @selectStr +
' group by 物料流水号,领料日期 ) as c on b.物料流水号 = c.物料流水号 and c.领料日期 = b.记录时间 left join (select sum(入库数) as 入库数,物料流水号,入库日期 from 仓储管理_入库记录_视图 where 1=1 '
if(@_check = 1)
set @selectStr = @selectStr + ' and 入库日期 >= @开始时间 and 入库日期 <= @结束时间 '
set @selectStr = @selectStr +
' group by 物料流水号,入库日期 ) as a on b.物料流水号 = a.物料流水号 and a.入库日期 = b.记录时间
inner join (select 物料编码,名称,代号,物料流水号,货位流水号,单位流水号 from 库存管理_物料主文件_基本 where 1 = 1 '
if(@_check = 1)
set @selectStr = @selectStr + ' and replace(isnull(名称,''''),'' '','''') + replace(isnull(代号,''''),'' '','''') + replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料名称,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStr = @selectStr + ' and replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料编码,'' '','''') + ''%'' '
set @selectStr = @selectStr +
' ) as d on b.物料流水号 = d.物料流水号 left join 单位名称_基础表 on d.单位流水号 = 单位名称_基础表.单位流水号
left join 库存管理_货位主文件 on d.货位流水号 = 库存管理_货位主文件.货位流水号 '
EXEC sp_executesql @selectStr,
N'@物料名称 nvarchar(50),@物料编码 nvarchar(50),@开始时间 datetime,@结束时间 datetime',
@,@,@,@
END
GO
ALTER PROCEDURE [dbo].[_仓储管理_物料记录_查询]
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ datetime = null,
@ datetime = null
AS
BEGIN
select '物料记录_' + replace(replace(replace(CONVERT(nvarchar(19),GETDATE(),21),':',''),'-',''),' ','-') as tablename,'15' as tabletype
select 256*15 as ,256*30 as ,256*30 as ,256*10 as ,256*15 as ,256*15 as ,256*15 as ,256*15 as ,256*15 as
select 0 as ,0 as ,0 as ,0 as ,1 as ,1 as ,1 as ,0 as ,0 as
declare @selectStr nvarchar(4000)
set @selectStr =
' select d.物料编码,名称,代号,单位名称_基础表.单位,isnull(出库数,0) as 出库数,isnull(入库数,0) as 入库数,isnull(库存数,0) as 库存数,库存管理_货位主文件.货位名称 as 库位,记录时间 from (select 物料流水号,库存数,convert(varchar(10),操作日期,23) as 记录时间 from 库存管理_每日库存结余表 where 1 = 1 '
if(@_check = 1)
set @selectStr = @selectStr + ' and convert(varchar(10),操作日期,23) >= @开始时间 and convert(varchar(10),操作日期,23) <= @结束时间 '
set @selectStr = @selectStr +
' ) as b left join (select sum(领料数) as 出库数,物料流水号,领料日期 from 仓储管理_出库记录_视图 where 1=1 '
if(@_check = 1)
set @selectStr = @selectStr + ' and 领料日期 >= @开始时间 and 领料日期 <= @结束时间 '
set @selectStr = @selectStr +
' group by 物料流水号,领料日期 ) as c on b.物料流水号 = c.物料流水号 and c.领料日期 = b.记录时间 left join (select sum(入库数) as 入库数,物料流水号,入库日期 from 仓储管理_入库记录_视图 where 1=1 '
if(@_check = 1)
set @selectStr = @selectStr + ' and 入库日期 >= @开始时间 and 入库日期 <= @结束时间 '
set @selectStr = @selectStr +
' group by 物料流水号,入库日期 ) as a on b.物料流水号 = a.物料流水号 and a.入库日期 = b.记录时间
inner join (select 物料编码,名称,代号,物料流水号,货位流水号,单位流水号 from 库存管理_物料主文件_基本 where 1 = 1 '
if(@_check = 1)
set @selectStr = @selectStr + ' and replace(isnull(名称,''''),'' '','''') + replace(isnull(代号,''''),'' '','''') + replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料名称,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStr = @selectStr + ' and replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料编码,'' '','''') + ''%'' '
set @selectStr = @selectStr +
' ) as d on b.物料流水号 = d.物料流水号 left join 单位名称_基础表 on d.单位流水号 = 单位名称_基础表.单位流水号
left join 库存管理_货位主文件 on d.货位流水号 = 库存管理_货位主文件.货位流水号 '
EXEC sp_executesql @selectStr,
N'@物料名称 nvarchar(50),@物料编码 nvarchar(50),@开始时间 datetime,@结束时间 datetime',
@,@,@,@
END
GO
ALTER PROCEDURE [dbo].[_盘点记录_查询]
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ datetime = null,
@ datetime = null
AS
BEGIN
declare @selectStr nvarchar(4000)
set @selectStr = ' select * from 库存管理_盘点记录_视图 where 1 = 1 '
if(@_check = 1)
set @selectStr = @selectStr + ' and replace(isnull(名称,''''),'' '','''') + replace(isnull(代号,''''),'' '','''') + replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料名称,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStr = @selectStr + ' and replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料编码,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStr = @selectStr + ' and convert(varchar(10),修改时间,23) >= @开始时间 and convert(varchar(10),修改时间,23) <= @结束时间 '
set @selectStr = @selectStr + ' order by 修改时间 desc '
EXEC sp_executesql @selectStr,
N'@物料名称 nvarchar(50),@物料编码 nvarchar(50),@开始时间 datetime,@结束时间 datetime',
@,@,@,@
END
GO
ALTER PROCEDURE [dbo].[_仓储管理_盘点记录_查询]
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ datetime = null,
@ datetime = null
AS
BEGIN
select '盘点记录_' + replace(replace(replace(CONVERT(nvarchar(19),GETDATE(),21),':',''),'-',''),' ','-') as tablename,'15' as tabletype
select 256*15 as ,256*30 as ,256*30 as ,256*10 as ,256*15 as ,256*15 as ,256*15 as ,256*25 as
select 0 as ,0 as ,0 as ,0 as ,1 as ,1 as ,0 as ,0 as
declare @selectStr nvarchar(4000)
set @selectStr = ' select * from 库存管理_盘点记录_视图 where 1 = 1 '
if(@_check = 1)
set @selectStr = @selectStr + ' and replace(isnull(名称,''''),'' '','''') + replace(isnull(代号,''''),'' '','''') + replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料名称,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStr = @selectStr + ' and replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料编码,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStr = @selectStr + ' and convert(varchar(10),修改时间,23) >= @开始时间 and convert(varchar(10),修改时间,23) <= @结束时间 '
EXEC sp_executesql @selectStr,
N'@物料名称 nvarchar(50),@物料编码 nvarchar(50),@开始时间 datetime,@结束时间 datetime',
@,@,@,@
END
GO
ALTER PROCEDURE [dbo].[_入库记录退货_条件查询]
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ nvarchar(50) = null,
@_check bit = null,
@ nvarchar(50) = null,
@ nvarchar(50) = null
AS
BEGIN
declare @selectStr nvarchar(4000)
declare @selectStrWhere nvarchar(4000)
set @selectStr = ' select * from [dbo].[仓储管理_入库记录退货_视图] '
set @selectStrWhere = ' where 1 = 1 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere + ' and 物料名称 + 图号或型号 like ''%'' + @物料名称 + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere + ' and 采购合同 like ''%'' + @采购合同 + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere + ' and 供应商 like ''%'' + @供应商 + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere + ' and replace(isnull(物料编码,''''),'' '','''') like ''%'' + replace(@物料编码,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere + ' and convert(varchar(10),退货时间,23) >= @开始时间 and convert(varchar(10),退货时间,23) <= @结束时间 '
set @selectStr = @selectStr + @selectStrWhere + ' order by 退货时间 desc '
EXEC sp_executesql @selectStr,
N'@物料名称 nvarchar(50),@采购合同 nvarchar(50),@供应商 nvarchar(50),@物料编码 nvarchar(50),@开始时间 nvarchar(50),@结束时间 nvarchar(50)',
@,@,@,@,@,@
END
GO