feat: previas con sitema de reservas refs #6861
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
32aafc3545
commit
ed7218c133
|
@ -48,21 +48,14 @@ BEGIN
|
||||||
|
|
||||||
IF vAvailable < vQuantity THEN
|
IF vAvailable < vQuantity THEN
|
||||||
SET vHasThrow = TRUE;
|
SET vHasThrow = TRUE;
|
||||||
SELECT vAvailable, vQuantity;
|
|
||||||
ELSE
|
ELSE
|
||||||
START TRANSACTION;
|
|
||||||
|
|
||||||
SELECT `name`,
|
SELECT `name`,
|
||||||
CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name)
|
CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name)
|
||||||
INTO vItemName, vConcept
|
INTO vItemName, vConcept
|
||||||
FROM item
|
FROM item
|
||||||
WHERE id = vItemFk;
|
WHERE id = vItemFk;
|
||||||
|
|
||||||
INSERT INTO ticketLog
|
START TRANSACTION;
|
||||||
SET originFk = vTicketFk,
|
|
||||||
userFk = getUser(),
|
|
||||||
`action` = 'update',
|
|
||||||
`description` = CONCAT('Añadido articulo ', vItemName, ' cantidad:', vQuantity);
|
|
||||||
|
|
||||||
INSERT INTO sale
|
INSERT INTO sale
|
||||||
SET itemFk = vItemFk,
|
SET itemFk = vItemFk,
|
||||||
|
@ -88,8 +81,9 @@ BEGIN
|
||||||
INSERT INTO saleGroupDetail
|
INSERT INTO saleGroupDetail
|
||||||
SET saleFk = vSaleFk,
|
SET saleFk = vSaleFk,
|
||||||
saleGroupFk = vSaleGroupFk;
|
saleGroupFk = vSaleGroupFk;
|
||||||
|
END IF;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
END IF;
|
END IF;
|
||||||
END IF ;
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_getAssigned`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_getAssigned`(
|
||||||
vUserFk INT,
|
vUserFk INT,
|
||||||
OUT vCollectionFk INT)
|
OUT vCollectionFk INT
|
||||||
proc:BEGIN
|
)
|
||||||
/* Comprueba si existen colecciones libres que se ajustan al perfil del usuario
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Comprueba si existen colecciones libres que se ajustan al perfil del usuario
|
||||||
* y le asigna la más antigua.
|
* y le asigna la más antigua.
|
||||||
* Añade un registro al semillero de colecciones y hace la reserva para la colección
|
* Añade un registro al semillero de colecciones y hace la reserva para la colección
|
||||||
|
*
|
||||||
* @param vUserFk Id de usuario
|
* @param vUserFk Id de usuario
|
||||||
* @param vCollectionFk Id de colección
|
* @param vCollectionFk Id de colección
|
||||||
*/
|
*/
|
||||||
|
@ -28,17 +31,16 @@ proc:BEGIN
|
||||||
CALL collection_get(vUserFk);
|
CALL collection_get(vUserFk);
|
||||||
|
|
||||||
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0,
|
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0,
|
||||||
collection_assign_lockname
|
pc.collection_assign_lockname
|
||||||
INTO vHasTooMuchCollections,
|
INTO vHasTooMuchCollections,
|
||||||
vLockName
|
vLockName
|
||||||
FROM tCollection
|
FROM tCollection tc
|
||||||
JOIN productionConfig pc ;
|
JOIN productionConfig pc;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tCollection;
|
DROP TEMPORARY TABLE tCollection;
|
||||||
|
|
||||||
IF vHasTooMuchCollections THEN
|
IF vHasTooMuchCollections THEN
|
||||||
CALL util.throw('Hay colecciones pendientes');
|
CALL util.throw('Hay colecciones pendientes');
|
||||||
LEAVE proc;
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT warehouseFk, itemPackingTypeFk
|
SELECT warehouseFk, itemPackingTypeFk
|
||||||
|
|
|
@ -26,7 +26,7 @@ BEGIN
|
||||||
JOIN vn.saleTracking st ON st.saleFk = sa.saleFk
|
JOIN vn.saleTracking st ON st.saleFk = sa.saleFk
|
||||||
JOIN vn.`state` s ON s.id = st.stateFk
|
JOIN vn.`state` s ON s.id = st.stateFk
|
||||||
WHERE st.isChecked
|
WHERE st.isChecked
|
||||||
AND s.semaphore = 1
|
AND s.`code` IN ('PREVIOUS_PREPARATION', 'OK PREVIOUS', 'OK STOWAWAY')
|
||||||
GROUP BY sa.saleFk
|
GROUP BY sa.saleFk
|
||||||
) SELECT s.saleFk
|
) SELECT s.saleFk
|
||||||
FROM sales s
|
FROM sales s
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_moveReserv`(
|
||||||
|
vItemShelvingFk INT(10),
|
||||||
|
vItemFk INT(10)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Elimina reservas de un itemShelvingSale e intenta reservar en otra ubicación
|
||||||
|
*
|
||||||
|
* @param vItemShelvingFk Id itemShelving
|
||||||
|
*/
|
||||||
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
|
BEGIN
|
||||||
|
ROLLBACK;
|
||||||
|
RESIGNAL;
|
||||||
|
END;
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
SELECT id INTO vItemShelvingFk
|
||||||
|
FROM itemShelving
|
||||||
|
WHERE id = vItemShelvingFk
|
||||||
|
AND FALSE
|
||||||
|
FOR UPDATE;
|
||||||
|
|
||||||
|
UPDATE itemShelving
|
||||||
|
SET visible = 0,
|
||||||
|
available = 0
|
||||||
|
WHERE id = vItemShelvingFk
|
||||||
|
AND itemFk = vItemFk;
|
||||||
|
|
||||||
|
INSERT INTO itemShelvingSaleReserv (saleFk)
|
||||||
|
SELECT DISTINCT iss.saleFk
|
||||||
|
FROM itemShelvingSale iss
|
||||||
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
|
WHERE iss.itemShelvingFk = vItemShelvingFk
|
||||||
|
AND ish.itemFk = vItemFk
|
||||||
|
AND NOT iss.isPicked;
|
||||||
|
|
||||||
|
DELETE iss
|
||||||
|
FROM itemShelvingSale iss
|
||||||
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
|
WHERE iss.itemShelvingFk = vItemShelvingFk
|
||||||
|
AND ish.itemFk = vItemFk
|
||||||
|
AND NOT iss.isPicked;
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
CALL itemShelvingSale_doReserve();
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setSaleGroup`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setPicked`(
|
||||||
vSaleGroupFk INT(10)
|
vSaleGroupFk INT(10)
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
|
@ -46,10 +46,8 @@ BEGIN
|
||||||
CALL util.throw('La cantidad no puede distinta a la reserva');
|
CALL util.throw('La cantidad no puede distinta a la reserva');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
|
|
||||||
UPDATE itemShelvingSale
|
UPDATE itemShelvingSale
|
||||||
SET isPicked = TRUE,
|
SET isPicked = TRUE,
|
||||||
quantity = vQuantity
|
quantity = vQuantity
|
||||||
|
@ -62,41 +60,10 @@ BEGIN
|
||||||
FOR UPDATE;
|
FOR UPDATE;
|
||||||
|
|
||||||
UPDATE itemShelving
|
UPDATE itemShelving
|
||||||
SET visible = IF(vIsItemShelvingSaleEmpty, 0, GREATEST(0, visible - vQuantity))
|
SET visible = GREATEST(0, visible - vQuantity)
|
||||||
WHERE id = vItemShelvingFk;
|
WHERE id = vItemShelvingFk;
|
||||||
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
|
|
||||||
|
|
||||||
UPDATE itemShelving
|
|
||||||
SET visible = 0,
|
|
||||||
available = 0
|
|
||||||
WHERE id = vItemShelvingFk
|
|
||||||
AND itemFk = vItemFk;
|
|
||||||
|
|
||||||
CALL itemShelvingSale_addBySale(vSaleFk);
|
|
||||||
|
|
||||||
START TRANSACTION;
|
|
||||||
|
|
||||||
INSERT INTO itemShelvingSaleReserv (saleFk)
|
|
||||||
SELECT DISTINCT iss.saleFk
|
|
||||||
FROM itemShelvingSale iss
|
|
||||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
|
||||||
WHERE iss.itemShelvingFk = vItemShelvingFk
|
|
||||||
AND ish.itemFk = vItemFk
|
|
||||||
AND NOT iss.isPicked;
|
|
||||||
|
|
||||||
DELETE iss
|
|
||||||
FROM itemShelvingSale iss
|
|
||||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
|
||||||
WHERE iss.itemShelvingFk = vItemShelvingFk
|
|
||||||
AND ish.itemFk = vItemFk
|
|
||||||
AND NOT iss.isPicked;
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
CALL itemShelvingSale_doReserve();
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity)
|
SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity)
|
||||||
INTO vRemainingQuantity, vTotalQuantity
|
INTO vRemainingQuantity, vTotalQuantity
|
||||||
|
@ -104,8 +71,6 @@ BEGIN
|
||||||
WHERE saleFk = vSaleFk;
|
WHERE saleFk = vSaleFk;
|
||||||
|
|
||||||
IF vRemainingQuantity = 0 THEN
|
IF vRemainingQuantity = 0 THEN
|
||||||
START TRANSACTION;
|
|
||||||
|
|
||||||
CALL saleTracking_new(
|
CALL saleTracking_new(
|
||||||
vSaleFk,
|
vSaleFk,
|
||||||
TRUE,
|
TRUE,
|
||||||
|
@ -119,8 +84,12 @@ BEGIN
|
||||||
SET s.quantity = vTotalQuantity,
|
SET s.quantity = vTotalQuantity,
|
||||||
isPicked = TRUE
|
isPicked = TRUE
|
||||||
WHERE s.id = vSaleFk;
|
WHERE s.id = vSaleFk;
|
||||||
|
END IF;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
|
||||||
|
CALL itemShelvingSale_moveReserv(vItemShelvingFk, vQuantity);
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -1,7 +1,8 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingTransfer`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`(
|
||||||
vItemShelvingFk INT,
|
vItemShelvingFk INT,
|
||||||
vShelvingFk VARCHAR(3))
|
vShelvingFk VARCHAR(10)
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Transfiere producto de una ubicación a otra, fusionando si coincide el
|
* Transfiere producto de una ubicación a otra, fusionando si coincide el
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_getPartial`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_getMyPartial`()
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas
|
* Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas
|
|
@ -2,28 +2,24 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1)
|
||||||
DETERMINISTIC
|
DETERMINISTIC
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Devuelve si sectorCollection tiene reservas
|
* Devuelve si sectorCollection tiene reservas
|
||||||
* @param vSelf Id de sectorCollection
|
* @param vSelf Id de sectorCollection
|
||||||
*
|
*
|
||||||
* returns BOOLEAN
|
* returns BOOLEAN
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DECLARE vHasSalesReserved BOOLEAN;
|
DECLARE vHasSalesReserved BOOLEAN;
|
||||||
|
|
||||||
|
SELECT DISTINCT COUNT(*) INTO vHasSalesReserved
|
||||||
SELECT DISTINCT COUNT(*)>0 INTO vHasSalesReserved
|
FROM sectorCollection sc
|
||||||
FROM vn.sectorCollection sc
|
JOIN sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk
|
||||||
JOIN vn.sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk
|
JOIN saleGroup sg ON sg.id = scsg.saleGroupFk
|
||||||
JOIN vn.saleGroup sg ON sg.id = scsg.saleGroupFk
|
JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
|
||||||
JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
|
JOIN sale s ON s.id = sgd.saleFk
|
||||||
JOIN vn.sale s ON s.id = sgd.saleFk
|
JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||||
JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
|
JOIN saleTracking st ON st.saleFk = s.id
|
||||||
JOIN vn.saleTracking st ON st.saleFk = s.id
|
|
||||||
WHERE sc.id = vSelf;
|
WHERE sc.id = vSelf;
|
||||||
|
|
||||||
RETURN vHasSalesReserved;
|
RETURN vHasSalesReserved;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert`
|
|
||||||
AFTER INSERT ON `itemShelving`
|
|
||||||
FOR EACH ROW
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO vn.itemShelvingLog(
|
|
||||||
itemShelvingFk,
|
|
||||||
workerFk,
|
|
||||||
accion,
|
|
||||||
itemFk,
|
|
||||||
shelvingFk,
|
|
||||||
visible,
|
|
||||||
`grouping`,
|
|
||||||
packing,
|
|
||||||
available
|
|
||||||
)
|
|
||||||
VALUES (
|
|
||||||
NEW.id,
|
|
||||||
NEW.userFk,
|
|
||||||
'CREA REGISTRO',
|
|
||||||
NEW.itemFk,
|
|
||||||
NEW.shelvingFk,
|
|
||||||
NEW.visible,
|
|
||||||
NEW.`grouping`,
|
|
||||||
NEW.packing,
|
|
||||||
NEW.available
|
|
||||||
);
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
Loading…
Reference in New Issue