feat: 增加LG-AGV接口并完善物料校验与报工逻辑

This commit is contained in:
XingCheng3
2026-07-16 16:46:06 +08:00
parent 7303ddde9a
commit dcec36611d
36 changed files with 1274 additions and 36 deletions

View File

@@ -0,0 +1,177 @@
ALTER PROCEDURE [dbo].[CallWebApi_FactoryMes_JobFinished]
@ nvarchar(50) = null,
@ nvarchar(50) = null,
@ nvarchar(100) = null
AS
BEGIN
SET NOCOUNT ON
declare @ datetime
declare @ datetime
declare @ datetime
declare @ int
declare @ int=0
declare @ bit = 0
if(@ like 'AC06%' and charindex('-', @) = 0)
begin
set @ = 1
end
-- 1、获取当前触发报工工件的开完工时间
select top(1)
@=[],
@=[],
@=[线],
@=,
@=
from [线]
where =@ and =@
order by ID desc
-- 如果开完工数据没有,手动报工使用当前时间兜底
if(@ is null or @ = '')
begin
SET @ = GETDATE()
SET @ = GETDATE()
SET @ = 0
SET @ = GETDATE()
SET @ = 1
end
-- 表1订单任务信息
SELECT TOP(1) a.[ID],[ID],[ID],[],[],,1 as ,
FORMAT(@, 'yyyy-MM-dd HH:mm:ss') as ,
FORMAT(@, 'yyyy-MM-dd HH:mm:ss') as ,
@ as ,
FORMAT(@, 'yyyy-MM-dd HH:mm:ss') as ,
b.
FROM [_派工订单_工序任务] a
inner join [_派工订单_执行计划] b on a.workOrderNo=b.
where a.workOrderNo=@ and a.=@
order by []
-- 2、获取检验信息
declare @Id_tagCF int=0
select top(1) @Id_tagCF=Id_tagCF
from []
where EngineID=@ and =@
order by Id_tagCF desc
-- 获取当前订单的物料号(产品编号)
declare @ nvarchar(100) = ''
select top(1) @ =
from [_派工订单_工序任务]
where workOrderNo=@ and =@
order by []
-- 获取该物料号+工序号下最新下发的模板ID
declare @ID nvarchar(100) = ''
select top(1) @ID = Id
from [MOM_检验模板]
where MaterialCode = @ and ProcedureCode = @
order by [] desc
if(@ = 1)
begin
declare @ int = 1
;with as
(
select
i.Id_tagCF,
i.EngineID,
i.,
i.,
row_number() over(partition by i.EngineID, i. order by i.Id_tagCF desc) as rn
from [] i
inner join [_派工订单_执行计划] p on p. = i.EngineID
where p. = @
and i. = @
and isnull(p., '') in ('1','2','3')
)
select @ = case when count(1) = 0 then @ else min(isnull(, 1)) end
from
where rn = 1
;with as
(
select
i.Id_tagCF,
i.EngineID,
i.,
row_number() over(partition by i.EngineID, i. order by i.Id_tagCF desc) as rn
from [] i
inner join [_派工订单_执行计划] p on p. = i.EngineID
where p. = @
and i. = @
and isnull(p., '') in ('1','2','3')
)
SELECT a.[],a.[Id_tagCF],a.[EngineID],
@ as ,
a.[],a. as ,
CASE
WHEN TRY_CAST(a.[TagValue] AS FLOAT) IS NOT NULL
THEN CAST(ROUND(CAST(a.[TagValue] AS FLOAT), 2) AS NVARCHAR(100))
ELSE a.[TagValue]
END AS TagValue,
[IsGoodBad] as ,,,,a.,
c.TemplateId as ID, t.Code as , c.LineNum as
FROM x
inner join [] a on a.Id_tagCF = x.Id_tagCF
LEFT JOIN MOM_检验模板_关联表 b ON a.TagID = b.TagID
LEFT JOIN MOM_检验模板_检验项目 c ON c.TemplateId = @ID AND c.InspectionItemName = b.
LEFT JOIN MOM_检验模板 t ON t.Id = @ID
where x.rn = 1
and a. != '备用'
and a.TagValue != '0'
order by a.EngineID, a.id desc
end
else if(@Id_tagCF = 0 or @Id_tagCF is null) -- 前端手动报工用
begin
SELECT [],[Id_tagCF],[EngineID],@ as ,[], as ,
CASE
WHEN TRY_CAST([TagValue] AS FLOAT) IS NOT NULL
THEN CAST(ROUND(CAST([TagValue] AS FLOAT), 2) AS NVARCHAR(100))
ELSE [TagValue]
END AS TagValue,
[IsGoodBad] as ,,,,,
'' as ID, '' as , '' as
FROM []
where Id_tagCF=2
order by id desc
end
else
begin
SELECT a.[],[Id_tagCF],[EngineID],@ as ,a.[],a. as ,
CASE
WHEN TRY_CAST(a.[TagValue] AS FLOAT) IS NOT NULL
THEN CAST(ROUND(CAST(a.[TagValue] AS FLOAT), 2) AS NVARCHAR(100))
ELSE a.[TagValue]
END AS TagValue,
[IsGoodBad] as ,,,,a.,
c.TemplateId as ID, t.Code as , c.LineNum as
FROM [] a
LEFT JOIN MOM_检验模板_关联表 b ON a.TagID = b.TagID
LEFT JOIN MOM_检验模板_检验项目 c ON c.TemplateId = @ID AND c.InspectionItemName = b.
LEFT JOIN MOM_检验模板 t ON t.Id = @ID
where EngineID=@ and a.=@ and Id_tagCF=@Id_tagCF and a. != '备用' and TagValue != '0'
order by a.id desc
end
-- 3、获取物料信息从PLC扫码物料记录读取
SELECT []
,[] as []
,[] as []
,'' as []
,[] as
,[]
,[]
,[]
,1 as []
FROM [dbo].[XD_物料记录]
where []=@ and []=@ and isnull([], '') != ''
order by []
-- 4、获取工时信息
END

View File

@@ -0,0 +1,63 @@
ALTER PROCEDURE [dbo].[_IOT接口_报工记录_是否报工判断]
@ nvarchar(50) = 'OP10',
@ nvarchar(50) = 'SA10025',
@ nvarchar(50) = '开工',
@ nvarchar(100) = null
AS
SET NOCOUNT ON
-- 已成功报工的工序不重复报工
declare @ int
select @ = count(1)
from _IOT接口_报工记录
where = @
and = @
and = @
and = 1
if(@ > 0)
begin
select 2 as result,@ + '订单号:'+@+'产品工序已'+@+',无需二次报工' as msg
return
end
-- 断路器主工位:静端进站开工,拐臂箱出站完工;副工位如 AC0603-1 不参与此判断
if(@ like 'AC06%' and charindex('-', @) = 0)
begin
declare @ nvarchar(100) = null
declare @ int = null
set @ = nullif(@, '')
if(@ is null)
begin
select top 1 @ =
from MOBY
where = @
order by ID desc
end
select top 1 @ = try_convert(int, )
from _派工订单_执行计划
where = @
if(@ is null)
begin
select 2 as result,@ + '订单号:'+@+'产品工序'+@+',未查询到工件编号['+isnull(@,'')+']对应的小机型' as msg
return
end
if(@ = '开工' and @ <> 1)
begin
select 2 as result,@ + '订单号:'+@+'产品工序开工,非静端不进行报工' as msg
return
end
if(@ = '完工' and @ <> 3)
begin
select 2 as result,@ + '订单号:'+@+'产品工序完工,非拐臂箱不进行报工' as msg
return
end
end
select 1 as result,'' as msg