更新销售合同/提成/业绩、精工工序工价/生产审核/工时统计、仓储盘点/库存/补货/入库/库房管理,新增提成设置/销售业绩/库房管理/入库单移动端等模块及SQL脚本

This commit is contained in:
Developer
2026-08-05 08:13:08 +08:00
parent 33549c3787
commit fd84f9d3ca
94 changed files with 14531 additions and 345 deletions

View File

@@ -0,0 +1,129 @@
USE [ERPTOOL_JY]
GO
-- 库存查询采购中排除已入库数据;修改人:Ld 修改时间:2026-07-23 16:39:41;
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,
@ int = null,
@ int = null
AS
declare @selectStr nvarchar(4000)
declare @selectStrWhere nvarchar(4000)
--(select _零件工艺计划_视图.,isnull(SUM() - SUM(_零件工艺计划_视图.) - SUM(P.),0) as from _零件工艺计划_视图 inner join (select , from dbo._零件工序 where dbo._零件工序. = 1) as n
-- 这是改动前
set @selectStr =
'Select 仓储管理_累计库存查询_视图.*,批次,isnull(需求量,0) as 需求量,毛坯库存,isnull(加工中,0) as 加工中,isnull(采购中,0) as 采购中,isnull(补货毛坯,0) as 补货毛坯 from 仓储管理_累计库存查询_视图
left join
(select count(*) as 批次,物料流水号 from 库存管理_物料与货位对照表 where 货位存量 > 0 group by 物料流水号)
as a on 仓储管理_累计库存查询_视图.物料流水号 = a.物料流水号 LEFT JOIN dbo.物料管理_需求量_视图 ON a.物料流水号 = dbo.物料管理_需求量_视图.物料流水号
left join
(select 车间生产管理_零件工艺计划_视图.物料流水号,isnull(SUM(数量) - SUM(车间生产管理_零件工艺计划_视图.入库数量) - ISNULL(SUM(P.报废数量),0),0) as 加工中 from 车间生产管理_零件工艺计划_视图 inner join (select 工艺计划流水号,工序流水号 from dbo.车间生产管理工艺_零件工序 where dbo.车间生产管理工艺_零件工序.工序顺序 = 1) as n
on 车间生产管理_零件工艺计划_视图.工艺计划流水号 = n.工艺计划流水号 inner join
(select SUM(ISNULL(已领数量,0)) as 数量,工序流水号 from 车间生产管理工艺_零件工序_任务分配 group by 工序流水号) as m on n.工序流水号 = m.工序流水号 left join
(select sum(报废数量) as 报废数量,工艺计划流水号 from 车间生产管理工艺_零件工艺计划_报废零件记录 group by 工艺计划流水号) as P on 车间生产管理_零件工艺计划_视图.工艺计划流水号 = P.工艺计划流水号 where 车间生产管理_零件工艺计划_视图.是否提交 < 5 and 车间生产管理_零件工艺计划_视图.考核状态 < 3
group by 物料流水号)
as D on 仓储管理_累计库存查询_视图.物料流水号 = D.物料流水号
left join
(select sum(isnull(采购数,0)-isnull(到货数,0)) as 采购中,物料流水号 from 采购管理_采购合同明细_全部_查询视图 where 是否滑台 <> 1 and 是否滑台 <> 2 and 已删 = 0 and 采购状态 <> ''已到'' and 采购状态 <> ''已入库''
GROUP BY 物料流水号)
as T on 仓储管理_累计库存查询_视图.物料流水号 = T.物料流水号
left join
(select isnull(sum(isnull(累计库存,0)),0) as 毛坯库存,库存管理_物料主文件_基本.代号,库存管理_物料主文件_基本.名称 from 库存管理_物料主文件_基本
left join 库存管理_外购件累计库存 on 库存管理_物料主文件_基本.物料流水号 = 库存管理_外购件累计库存.物料流水号 where 库存管理_物料主文件_基本.是否禁用 = 0 group by 库存管理_物料主文件_基本.代号,库存管理_物料主文件_基本.名称) as C on 仓储管理_累计库存查询_视图.图号或型号 + ''MP'' = C.代号 AND 仓储管理_累计库存查询_视图.物料名称 + ''MP'' = C.名称
left join
(SELECT dbo.库存管理_物料主文件_基本.名称, dbo.库存管理_物料主文件_基本.代号, isnull(SUM(dbo.采购管理_采购合同明细.数量 - dbo.采购管理_采购合同明细.已到货数量),0) AS 补货毛坯
FROM dbo.采购管理_采购合同明细 INNER JOIN
dbo.PDM_零件明细表_标准件和外购件 ON dbo.采购管理_采购合同明细.标准件和外购件流水号 = dbo.PDM_零件明细表_标准件和外购件.标准件和外购件流水号 INNER JOIN
dbo.库存管理_物料主文件_基本 ON dbo.PDM_零件明细表_标准件和外购件.物料流水号 = dbo.库存管理_物料主文件_基本.物料流水号
GROUP BY dbo.库存管理_物料主文件_基本.名称, dbo.库存管理_物料主文件_基本.代号) as E on 仓储管理_累计库存查询_视图.图号或型号 + ''MP'' = E.代号 AND 仓储管理_累计库存查询_视图.物料名称 + ''MP'' = E.名称 '
set @selectStrWhere = 'where 1 = 1 '
--2024-04-29isnull(SUM( - _零件工艺计划_视图. - P.),0) as
--isnull(SUM() - SUM(_零件工艺计划_视图.) - SUM(P.),0) as
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and isnull(物料名称,'''') like + ''%'' + @物料名称 + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and isnull(物料编码,'''') like + ''%'' + @物料编码 + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and isnull(图号或型号,'''') like + ''%'' + @图号 + ''%'' '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and 类型 = @类型 '
if(@_check = 1)
set @selectStrWhere = @selectStrWhere+' and isnull(货位名称,'''') 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
begin
set @selectStr = @selectStr+@selectStrWhere
end
print @selectStr
EXEC sp_executesql @selectStr,N'@物料名称 nvarchar(50),@物料编码 nvarchar(50), @图号 nvarchar(50),@类型 nvarchar(50),@库位 nvarchar(50)',
@,@,@,@,@
GO