This commit is contained in:
parent
aa2d3be451
commit
c62e6fa0eb
|
@ -0,0 +1,63 @@
|
|||
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 vNewCollectionFk INT;
|
||||
DECLARE vIsAdvanced BOOL;
|
||||
DECLARE vOldCollectionFk INT;
|
||||
DECLARE vIsPackingByOther BOOL;
|
||||
|
||||
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;
|
||||
|
||||
SELECT collectionFk INTO vOldCollectionFk
|
||||
FROM packingSite WHERE id = vSelf;
|
||||
|
||||
IF NOT (vOldCollectionFk <=> vNewCollectionFk) THEN
|
||||
SELECT COUNT(*) > 0
|
||||
INTO vIsPackingByOther
|
||||
FROM packingSite
|
||||
WHERE id <> vSelf
|
||||
AND collectionFk = vOldCollectionFk;
|
||||
|
||||
IF NOT vIsPackingByOther AND NOT collection_isPacked(vOldCollectionFk) AND vSelf IS NOT NULL THEN
|
||||
CALL util.throw('cannotChangeCollection');
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
UPDATE packingSite SET collectionFk = vNewCollectionFk
|
||||
WHERE id = vSelf;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
|
|
@ -100,5 +100,8 @@
|
|||
},
|
||||
"TicketConfig": {
|
||||
"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