2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`collectionVolumetry_afterUpdate`
|
2024-01-15 11:31:03 +00:00
|
|
|
AFTER UPDATE ON `collectionVolumetry`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
DECLARE vJSON JSON DEFAULT JSON_OBJECT();
|
|
|
|
DECLARE vUserFk INT DEFAULT account.myUser_getId();
|
|
|
|
|
|
|
|
IF NOT (NEW.id <=> OLD.id) THEN
|
|
|
|
SET vJSON = JSON_MERGE(JSON_OBJECT('id', NEW.id), vJSON);
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
IF NOT (NEW.`level` <=> OLD.`level`) THEN
|
|
|
|
SET vJSON = JSON_MERGE(JSON_OBJECT('level', NEW.`level`), vJSON);
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
IF NOT (NEW.`lines` <=> OLD.`lines`) THEN
|
|
|
|
SET vJSON = JSON_MERGE(JSON_OBJECT('lines', NEW.`lines`), vJSON);
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
IF NOT (NEW.liters <=> OLD.liters) THEN
|
|
|
|
SET vJSON = JSON_MERGE(JSON_OBJECT('liters', NEW.liters), vJSON);
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
IF NOT (NEW.height <=> OLD.height) THEN
|
|
|
|
SET vJSON = JSON_MERGE(JSON_OBJECT('height', NEW.height), vJSON);
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
IF NOT (NEW.itemPackingTypeFk <=> OLD.itemPackingTypeFk) THEN
|
|
|
|
SET vJSON = JSON_MERGE(JSON_OBJECT('itemPackingTypeFk', NEW.itemPackingTypeFk), vJSON);
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
IF NOT (NEW.trainFk <=> OLD.trainFk) THEN
|
|
|
|
SET vJSON = JSON_MERGE(JSON_OBJECT('trainFk', NEW.trainFk), vJSON);
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
SET vJSON = JSON_MERGE(JSON_OBJECT('userFk', vUserFk), vJSON);
|
|
|
|
SET vJSON = JSON_MERGE(JSON_OBJECT('action', 'update'), vJSON);
|
|
|
|
|
|
|
|
SET vJSON = util.notification_send(
|
|
|
|
'modified-collection-volumetry',
|
|
|
|
JSON_OBJECT('data', JSON_EXTRACT(vJSON, '$')),
|
|
|
|
vUserFk
|
|
|
|
);
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|