Merge pull request 'refs #5651 packingSiteAdvanced' (!1615) from 5651-packingSiteAdvanced into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1615 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
a43792be26
|
@ -0,0 +1,71 @@
|
||||||
|
CREATE TABLE `vn`.`packingSiteAdvanced` (
|
||||||
|
`ticketFk` int(11),
|
||||||
|
`workerFk` int(10) unsigned,
|
||||||
|
PRIMARY KEY (`ticketFk`),
|
||||||
|
KEY `packingSiteAdvanced_FK_1` (`workerFk`),
|
||||||
|
CONSTRAINT `packingSiteAdvanced_FK` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `packingSiteAdvanced_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('PackingSiteAdvanced', '*', '*', 'ALLOW', 'ROLE', 'production');
|
||||||
|
|
||||||
|
DROP PROCEDURE IF EXISTS `vn`.`packingSite_startCollection`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`packingSite_startCollection`(vSelf INT, vTicketFk INT)
|
||||||
|
proc: BEGIN
|
||||||
|
/**
|
||||||
|
* @param vSelf packingSite id
|
||||||
|
* @param vTicketFk A ticket id from the collection to start
|
||||||
|
*/
|
||||||
|
DECLARE vExists BOOL;
|
||||||
|
DECLARE vIsAdvanced BOOL;
|
||||||
|
DECLARE vNewCollectionFk INT;
|
||||||
|
DECLARE vOldCollectionFk INT;
|
||||||
|
DECLARE vIsPackingByOther BOOL;
|
||||||
|
|
||||||
|
SELECT id, collectionFk
|
||||||
|
INTO vExists, vOldCollectionFk
|
||||||
|
FROM packingSite
|
||||||
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
IF NOT vExists THEN
|
||||||
|
CALL util.throw('packingSiteNotExists');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*) > 0
|
||||||
|
INTO vIsAdvanced
|
||||||
|
FROM packingSiteAdvanced
|
||||||
|
WHERE ticketFk = vTicketFk;
|
||||||
|
|
||||||
|
IF vIsAdvanced THEN
|
||||||
|
LEAVE proc;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT collectionFk INTO vNewCollectionFk
|
||||||
|
FROM ticketCollection WHERE ticketFk = vTicketFk;
|
||||||
|
|
||||||
|
IF vOldCollectionFk IS NOT NULL
|
||||||
|
AND vOldCollectionFk <> vNewCollectionFk THEN
|
||||||
|
SELECT COUNT(*) > 0
|
||||||
|
INTO vIsPackingByOther
|
||||||
|
FROM packingSite
|
||||||
|
WHERE id <> vSelf
|
||||||
|
AND collectionFk = vOldCollectionFk;
|
||||||
|
|
||||||
|
IF NOT vIsPackingByOther AND NOT collection_isPacked(vOldCollectionFk) THEN
|
||||||
|
CALL util.throw('cannotChangeCollection');
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
UPDATE packingSite SET collectionFk = vNewCollectionFk
|
||||||
|
WHERE id = vSelf;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100,5 +100,8 @@
|
||||||
},
|
},
|
||||||
"TicketConfig": {
|
"TicketConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"PackingSiteAdvanced": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "PackingSiteAdvanced",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "packingSiteAdvanced"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"ticketFk": {
|
||||||
|
"id": true,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"workerFk": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue