CREATE TRIGGER [dbo].Fu_ICMO
on [dbo].ICMO
For INSERT
AS
SET NOCOUNT ON
DECLARE @NUMBER int; --声明变量:NUMBER
select @NUMBER = FItemID from inserted --取当前插入记录的物料内码赋值给@NUMBER
/*更新生产任务单工时和BOM描述*/
update ICMO --更新生产任务单工时
set FHeadSelfJ01108 = c.f1,
FHeadSelfJ0197 = b.fnote --BOM描述 = BOM表.备注
from ICMO a --生产任务单
join t_RoutingOper b --工艺路线表体
on a.FRoutingID = b.FInterID --生产任务单.工艺路线 = 工艺路线表体.表头内码
and a.FItemID = @NUMBER --生产任务单.物料内码 = 当前出入的物料内码
join (select FInterID, sum(FPersonStdTimeRun) f1 --表头内码,汇总标准人工运行工时f1
from t_RoutingOper --工艺路线表体
group by FInterID --表头内码
)c
on b.FInterID = c.FInterID --工艺路线表体.表头内码 = c.表头内码
join ICBOM d --BOM表 b
on a.FBomInterID = b.FInterID
and a.FItemID = @NUMBER --生产任务单.物料内码 = 当前出入的物料内码
--生产任务单.BOM编号 = BOM表.BOM内码
and isnull(a.FHeadSelfJ0197, 'a') <> b.fnote
--判断生产任务单.BOM描述是否为NULL,为NULL返回‘a’ <> BOM表.备注
and isnull(a.FHeadSelfJ0197, '') = ''
--判断生产任务单.BOM描述是否为NULL,为NULL返回‘ ’ = ''
更新生产任务单工时和BOM描述
最新推荐文章于 2023-02-07 15:48:12 发布