更新装配、精工车间、技术中心、仓储模块,新增工序工价、生产审核、三楼仓库可视化等功能及文档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,238 @@
-- 入库记录查询关联入库单去重修正
-- 修改人:Ld 修改时间:2026-07-02 16:50:22;
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,
@ datetime = null,
@ datetime = null,
@_check bit = null,
@ int = null,
@_check bit = null,
@ nvarchar(50) = null,
@ int =null,
@ int =null,
@_check bit = null,
@ varchar(50) = null
AS
declare @selectStr nvarchar(4000)
declare @selectStrWhere nvarchar(4000)
set @selectStr =
-- 修改人:Ld 修改时间:2026-07-02 16:50:22; 入库单先按采购合同流水号聚合,避免一合同多入库单行导致入库记录重复。
' select A.*,1 as 打印条码数,库存管理_物料主文件_基本.物料编码,采购管理_供应商.供应商编号,货位名称,isnull(累计库存,0) as 库存,入库单去重.入库单号 from (SELECT *
FROM 仓储管理_采购入库记录_视图
UNION ALL
SELECT *
FROM 仓储管理_自制入库记录_视图
UNION ALL
SELECT *
FROM 仓储管理_退料入库记录_视图
UNION ALL
SELECT *
FROM 仓储管理_通用入库记录_视图
UNION ALL
SELECT *
FROM 仓储管理_耗材采购入库记录_视图
UNION ALL
SELECT *
FROM 仓储管理_备货入库记录_视图) AS A LEFT JOIN
库存管理_物料主文件_基本 ON A.物料流水号 = 库存管理_物料主文件_基本.物料流水号 LEFT JOIN
采购管理_供应商 ON A.供应商流水号 = 采购管理_供应商.供应商流水号 LEFT JOIN
库存管理_货位主文件 ON 库存管理_物料主文件_基本.货位流水号 = 库存管理_货位主文件.货位流水号 LEFT JOIN
库存管理_外购件累计库存 ON 库存管理_物料主文件_基本.物料流水号 = 库存管理_外购件累计库存.物料流水号 LEFT JOIN
(SELECT 采购合同流水号, MAX(入库单号) AS 入库单号 FROM 仓储管理_入库单 GROUP BY 采购合同流水号) AS 入库单去重 ON A.采购合同流水号 = 入库单去重.采购合同流水号 '
set @selectStrWhere = 'where 1 = 1 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and replace(isnull(物料名称,''''),'' '','''') + replace(isnull(图号或型号,''''),'' '','''') + 批次编号 like + ''%'' + replace(@物料名称,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and replace(isnull(库存管理_物料主文件_基本.物料编码,''''),'' '','''') like + ''%'' + replace(@物料编码,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and 入库日期 >=@开始时间 and 入库日期 <=@结束时间 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and 订单号 like + ''%'' + @订单号 + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and A.类型 = @类型 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and A.采购合同流水号 = @采购合同流水号 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and 供应商 = @供应商名称 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and 入库单号 like + ''%'' + @入库单号 + ''%'' '
if @ = 1
begin
if @ = 1
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 物料编码 DESC'
end
else
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 物料编码 ASC'
end
end
else if @ = 2
begin
if @ = 1
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 物料名称 DESC'
end
else
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 物料名称 ASC'
end
end
else if @ = 3
begin
if @ = 1
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 图号或型号 DESC'
end
else
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 图号或型号 ASC'
end
end
else if @ = 4
begin
if @ = 1
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 货位名称 DESC'
end
else
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 货位名称 ASC'
end
end
else if @ = 5
begin
if @ = 1
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 批次编号 DESC'
end
else
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 批次编号 ASC'
end
end
else if @ = 6
begin
if @ = 1
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 供应商编号 DESC'
end
else
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 供应商编号 ASC'
end
end
else if @ = 7
begin
if @ = 1
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 采购合同编号 DESC'
end
else
begin
set @selectStr = @selectStr+@selectStrWhere+'order by 采购合同编号 ASC'
end
end
else
begin
set @selectStr = @selectStr+@selectStrWhere + ' order by 入库日期 desc '
end
EXEC sp_executesql @selectStr,N'@物料名称 nvarchar(50),@物料编码 nvarchar(50),@开始时间 datetime,@结束时间 datetime,@订单号 nvarchar(50),@类型 nvarchar(50),@采购合同流水号 int,@供应商名称 nvarchar(50),@入库单号 nvarchar(50) ',
@,@,@,@,@,@,@,@,@
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,
@_check bit = null,
@ datetime = null,
@ datetime = null,
@_check bit = null,
@ int = null,
@_check bit = null,
@ nvarchar(50) = null
AS
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*20 as [/],256*15 as ,256*15 as ,256*15 as ,246*20 as ,256*30 as ,
256*30 as ,256*15 as ,256*30 as ,256*20 as ,256*30 as ,256*20 as [/],256*20 as
select 0 as ,0 as ,0 as ,0 as [/],0 as ,1 as ,0 as ,0 as ,0 as
,0 as ,0 as ,0 as ,0 as ,0 as ,0 as [/],0 as
declare @selectStr nvarchar(4000)
declare @selectStrWhere nvarchar(4000)
set @selectStr =
-- 修改人:Ld 修改时间:2026-07-02 16:50:22; 入库单先按采购合同流水号聚合,保持导出与页面查询去重口径一致。
' select A.类型,库存管理_物料主文件_基本.物料编码 AS 物料编号,A.物料名称,A.图号或型号 AS [图号/型号],A.单位,A.入库数,货位名称,A.入库日期,
A.批次编号,采购管理_供应商.供应商编号,A.供应商,A.采购合同编号 AS 采购合同,A.订单号,A.产品名称 AS [产品/组件名称],A.备注,入库单去重.入库单号 from (SELECT *
FROM 仓储管理_采购入库记录_视图
UNION ALL
SELECT *
FROM 仓储管理_自制入库记录_视图
UNION ALL
SELECT *
FROM 仓储管理_退料入库记录_视图
UNION ALL
SELECT *
FROM 仓储管理_通用入库记录_视图
UNION ALL
SELECT *
FROM 仓储管理_耗材采购入库记录_视图
UNION ALL
SELECT *
FROM 仓储管理_备货入库记录_视图) AS A LEFT JOIN
库存管理_物料主文件_基本 ON A.物料流水号 = 库存管理_物料主文件_基本.物料流水号 LEFT JOIN
采购管理_供应商 ON A.供应商流水号 = 采购管理_供应商.供应商流水号 LEFT JOIN
库存管理_货位主文件 ON 库存管理_物料主文件_基本.货位流水号 = 库存管理_货位主文件.货位流水号 LEFT JOIN
(SELECT 采购合同流水号, MAX(入库单号) AS 入库单号 FROM 仓储管理_入库单 GROUP BY 采购合同流水号) AS 入库单去重 ON A.采购合同流水号 = 入库单去重.采购合同流水号 '
set @selectStrWhere = 'where 1 = 1 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and replace(isnull(物料名称,''''),'' '','''') + replace(isnull(图号或型号,''''),'' '','''') like + ''%'' + replace(@物料名称,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and replace(isnull(库存管理_物料主文件_基本.物料编码,''''),'' '','''') like + ''%'' + replace(@物料编码,'' '','''') + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and 入库日期 >=@开始时间 and 入库日期 <=@结束时间 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and 订单号 like + ''%'' + @订单号 + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and A.类型 = @类型 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and 采购合同流水号 = @采购合同流水号 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and 供应商 = @供应商名称 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and 入库单号 like + ''%'' + @入库单号 + ''%'' '
set @selectStr = @selectStr+@selectStrWhere+'order by 入库日期 DESC'
EXEC sp_executesql @selectStr,N'@物料名称 nvarchar(50),@物料编码 nvarchar(50),@开始时间 datetime,@结束时间 datetime,@订单号 nvarchar(50),@类型 nvarchar(50),@采购合同流水号 int,@供应商名称 nvarchar(50),@入库单号 nvarchar(50) ',
@,@,@,@,@,@,@,@,@
GO